Lolly 1.4.27
Loading...
Searching...
No Matches
Functions
hashset_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "hashset.hpp"
#include "string.hpp"
Include dependency graph for hashset_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("test contains")
 
 TEST_CASE ("test init")
 
 TEST_CASE ("test remove")
 
 TEST_CASE ("test operator <=")
 
 TEST_CASE ("test copy")
 

Function Documentation

◆ TEST_CASE() [1/5]

TEST_CASE ( "test contains" )

Definition at line 5 of file hashset_test.cpp.

5 {
6 auto set= hashset<string> ();
7 set->insert ("Hello");
8 CHECK_EQ (set->contains ("Hello"), true);
9 CHECK_EQ (set->contains ("hello"), false);
10 auto empty= hashset<string> ();
11 CHECK_EQ (set->contains ("hello"), false);
12}
The list class represents a linked list.
Definition list.hpp:48

◆ TEST_CASE() [2/5]

TEST_CASE ( "test init" )

Definition at line 14 of file hashset_test.cpp.

14 {
15 auto set= hashset<string> ();
16 set << string ("hello") << string ("world");
17 CHECK_EQ (set->contains ("hello"), true);
18 CHECK_EQ (set->contains ("world"), true);
19 CHECK_EQ (N (set), 2);
20}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170

◆ TEST_CASE() [3/5]

TEST_CASE ( "test remove" )

Definition at line 22 of file hashset_test.cpp.

22 {
23 auto set1= hashset<string> ();
24 auto set2= hashset<string> ();
25 CHECK_EQ (N (set1), N (set2));
26 set1 << string ("aaa") << string ("bbb");
27 CHECK_EQ (N (set1), N (set2) + 2);
28 set2 << string ("aaa") << string ("bbb") << string ("ccc");
29 set2->remove (string ("bbb"));
30 CHECK_EQ (N (set1), N (set2));
31}

◆ TEST_CASE() [4/5]

TEST_CASE ( "test operator <=" )

Definition at line 33 of file hashset_test.cpp.

33 {
34 auto out= tm_ostream ();
35 auto set= hashset<string> ();
36 set << string ("aaa") << string ("bbb");
37 auto set1= hashset<string> ();
38 set1 << string ("aaa") << string ("bbb") << string ("ccc");
39 auto out1= tm_ostream ();
40 CHECK_EQ (set <= set1, true);
41}

◆ TEST_CASE() [5/5]

TEST_CASE ( "test copy" )

Definition at line 43 of file hashset_test.cpp.

43 {
45 set1 << string ("a") << string ("b") << string ("c");
46 set2= copy (set1);
47 CHECK_EQ (set2->contains (string ("a")), true);
48 CHECK_EQ (set2->contains (string ("b")), true);
49 CHECK_EQ (set2->contains (string ("c")), true);
50 CHECK_EQ (N (set1) == N (set2), true);
51 // Test utf-8 for Chinese
52 set1 << string ("你好") << string ("世界");
53 set2= copy (set1);
54 CHECK_EQ (set2->contains (string ("你好")), true);
55 CHECK_EQ (set2->contains (string ("世界")), true);
56}
int copy(int x)
Returns a copy of an integer.
Definition basic.hpp:249