Changeset 9315761 in mainline
- Timestamp:
- 2018-07-05T21:41:18Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b1b500b
- Parents:
- dc0fff11
- git-author:
- Jaroslav Jindrak <dzejrou@…> (2017-10-30 13:48:33)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
- Location:
- uspace/lib/cpp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/test/tests.hpp
rdc0fff11 r9315761 67 67 private: 68 68 void test_construction_and_assignment(); 69 void test_append(); 69 70 }; 70 71 } -
uspace/lib/cpp/src/internal/test/string.cpp
rdc0fff11 r9315761 37 37 { 38 38 test_construction_and_assignment(); 39 test_append(); 39 40 40 41 return true; … … 81 82 std::string str4{}; 82 83 test_eq( 83 "default constr cutor empty",84 "default constructor empty", 84 85 str4.size(), 0ul 85 86 ); … … 87 88 str4.assign(str3, 2ul, 2ul); 88 89 test_eq( 89 "assign substring to empty string",90 "assign substring to an empty string", 90 91 str4.begin(), str4.end(), 91 92 str3.begin() + 2, str3.begin() + 4 … … 99 100 ); 100 101 } 102 103 void string_test::test_append() 104 { 105 std::string check{"hello, world"}; 106 107 std::string str1{"hello, "}; 108 str1.append("world"); 109 test_eq( 110 "append cstring", 111 str1.begin(), str1.end(), 112 check.begin(), check.end() 113 ); 114 115 std::string str2{"hello, "}; 116 str2.append(std::string{"world"}); 117 test_eq( 118 "append rvalue string", 119 str2.begin(), str2.end(), 120 check.begin(), check.end() 121 ); 122 123 std::string str3{"hello, "}; 124 std::string apendee{"world"}; 125 str3.append(apendee); 126 test_eq( 127 "append lvalue string", 128 str3.begin(), str3.end(), 129 check.begin(), check.end() 130 ); 131 132 std::string str4{"hello, "}; 133 str4.append(apendee.begin(), apendee.end()); 134 test_eq( 135 "append iterator range", 136 str4.begin(), str4.end(), 137 check.begin(), check.end() 138 ); 139 140 std::string str5{"hello, "}; 141 str5.append({'w', 'o', 'r', 'l', 'd', '\0'}); 142 test_eq( 143 "append initializer list", 144 str5.begin(), str5.end(), 145 check.begin(), check.end() 146 ); 147 148 std::string str6{"hello, "}; 149 str6 += "world"; 150 test_eq( 151 "append using +=", 152 str6.begin(), str6.end(), 153 check.begin(), check.end() 154 ); 155 } 101 156 }
Note:
See TracChangeset
for help on using the changeset viewer.