Lolly 1.4.28
Loading...
Searching...
No Matches
Functions
parse_string_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "parse_string.hpp"
#include <cassert>
#include <iostream>
Include dependency graph for parse_string_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("test for test()")
 
 TEST_CASE ("test for operator[] and getchar()")
 
 TEST_CASE ("test for get_string()")
 
 TEST_CASE ("test for write() and read()")
 
 TEST_CASE ("test for bool")
 
 TEST_CASE ("test for operator+= and advance()")
 

Function Documentation

◆ TEST_CASE() [1/6]

TEST_CASE ( "test for test()" )

Definition at line 7 of file parse_string_test.cpp.

7 {
8 parse_string s1, s2 ("abc"), s3 (" ");
9 parse_string s4 ("\t\b\0");
10 CHECK_EQ (test (s1, ""), true);
11 CHECK_EQ (test (s2, "ab"), true);
12 CHECK_EQ (test (s3, " "), true);
13 CHECK_EQ (test (s4, "\t\b"), true);
14 CHECK_EQ (test (s3, ""), true);
15
16 CHECK_EQ (!test (s3, "asdf"), true);
17 CHECK_EQ (!test (s4, "1234"), true);
18}
bool test(string s, int i, const char *test)
Definition analyze.cpp:542
The list class represents a linked list.
Definition list.hpp:48

◆ TEST_CASE() [2/6]

TEST_CASE ( "test for operator []and getchar()" )

Definition at line 20 of file parse_string_test.cpp.

20 {
22 parse_string s2 (" 123456789abcd~!@#$");
23 string str ('0', 300);
24 str << "1";
25 parse_string s3 (str);
26 CHECK_EQ (s2[0] == ' ', true);
27 CHECK_EQ (s2[9] == '9', true);
28 CHECK_EQ (s2[14] == '~', true);
29 CHECK_EQ (s3[300] == '1', true);
30 CHECK_EQ (s2[-1] == '\0', true);
31
32 CHECK_EQ (s1[2] != '2', true);
33 CHECK_EQ (s2[18] != '#', true);
34 CHECK_EQ (s2[0] != '0', true);
35 CHECK_EQ (s2[100] != '$', true);
36}

◆ TEST_CASE() [3/6]

TEST_CASE ( "test for get_string()" )

Definition at line 38 of file parse_string_test.cpp.

38 {
39 parse_string s1 ("\t\b"), s2;
40 s1->write ("!@#$");
41 s1->write ("0123");
42 s1->write ("");
43 CHECK_EQ (s2->get_string (0) == "", true);
44 CHECK_EQ (s1->get_string (0) == "", true);
45 CHECK_EQ (s1->get_string (1) == "0", true);
46 CHECK_EQ (s1->get_string (2) == "01", true);
47 CHECK_EQ (s1->get_string (6) == "0123!@", true);
48 CHECK_EQ (s1->get_string (9) == "0123!@#$\t", true);
49 CHECK_EQ (s1->get_string (12) == "0123!@#$\t\b", true);
50
51 CHECK_EQ (s2->get_string (0) != " ", true);
52 CHECK_EQ (s1->get_string (0) != "0", true);
53 CHECK_EQ (s1->get_string (1) != "", true);
54 CHECK_EQ (s1->get_string (2) != "!@", true);
55 CHECK_EQ (s1->get_string (15) != "", true);
56}

◆ TEST_CASE() [4/6]

TEST_CASE ( "test for write() and read()" )

Definition at line 58 of file parse_string_test.cpp.

58 {
59 parse_string s1 ("\t\b");
60 s1->write ("!@#$");
61 s1->write ("0123");
62 s1->write ("");
63 CHECK_EQ (s1[4] == '!', true);
64 CHECK_EQ (s1[7] == '$', true);
65 CHECK_EQ (test (s1, "0123!@#$\t\b"), true);
66
67 CHECK_EQ (s1->read (3) == "012", true);
68 CHECK_EQ (s1->read (1) == "3", true);
69 CHECK_EQ (s1->read (5) == "!@#$\t", true);
70 CHECK_EQ (s1->read (2) == "\b", true);
71 CHECK_EQ (s1->read (2) == "", true);
72}

◆ TEST_CASE() [5/6]

TEST_CASE ( "test for bool" )

Definition at line 74 of file parse_string_test.cpp.

74 {
75 parse_string s1, s2 ("a)3"), s3 (" ");
76 parse_string s4 ("\0"), s5 ("\t");
77 CHECK_EQ (s2 == true, true);
78 CHECK_EQ (s3 == true, true);
79 CHECK_EQ (s4 == true, true);
80 CHECK_EQ (s5 == true, true);
81
82 CHECK_EQ (s1 == false, true);
83}

◆ TEST_CASE() [6/6]

TEST_CASE ( )

Definition at line 85 of file parse_string_test.cpp.

85 {
86 parse_string s1 ("\t\b");
87 s1->write ("!@#$");
88 s1->write ("0123");
89 s1->write ("");
90 s1+= 1;
91 CHECK_EQ (s1[0] == '1', true);
92 CHECK_EQ (s1[9] == '\0', true);
93 s1+= 3;
94 CHECK_EQ (s1[0] == '!', true);
95 CHECK_EQ (s1[4] == '\t', true);
96 s1+= 6;
97 CHECK_EQ (s1[0] == '\0', true);
98 CHECK_EQ (s1[-1] != '\b', true);
99}