Skip to content

Commit 4e67650

Browse files
update cases for C++ string
1 parent ddc8c21 commit 4e67650

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

code/tests/cases/test_bdd.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* -----------------------------------------------------------------------------
1414
*/
1515
#include <fossil/test/framework.h>
16+
#include <string>
1617

1718
// * * * * * * * * * * * * * * * * * * * * * * * *
1819
// * Fossil Logic Test Utilites
@@ -106,32 +107,32 @@ FOSSIL_TEST_CASE(cpp_xbdd_empty_cart) {
106107
FOSSIL_TEST_CASE(cpp_xbdd_valid_login) {
107108
GIVEN("a registered user with valid credentials") {
108109
// Set up the context
109-
const char* validUsername = "user123";
110-
const char* validPassword = "pass456";
110+
std::string validUsername = "user123";
111+
std::string validPassword = "pass456";
111112

112113
WHEN("the user provides correct username and password") {
113114
// Perform the action of user login
114-
const char* inputUsername = "user123";
115-
const char* inputPassword = "pass456";
115+
std::string inputUsername = "user123";
116+
std::string inputPassword = "pass456";
116117

117118
THEN("the login should be successful") {
118119
// Check the expected outcome
119120
// Simulate login validation
120-
FOSSIL_TEST_ASSUME(strcmp(inputUsername, validUsername) == 0, "Username should match");
121-
FOSSIL_TEST_ASSUME(strcmp(inputPassword, validPassword) == 0, "Password should match");
121+
FOSSIL_TEST_ASSUME(inputUsername == validUsername, "Username should match");
122+
FOSSIL_TEST_ASSUME(inputPassword == validPassword, "Password should match");
122123
}
123124
}
124125

125126
WHEN("the user provides incorrect password") {
126127
// Perform the action of user login
127-
const char* inputUsername = "user123";
128-
const char* inputPassword = "wrongpass";
128+
std::string inputUsername = "user123";
129+
std::string inputPassword = "wrongpass";
129130

130131
THEN("the login should fail with an error message") {
131132
// Check the expected outcome
132133
// Simulate login validation
133-
FOSSIL_TEST_ASSUME(strcmp(inputUsername, validUsername) == 0, "Username should match");
134-
FOSSIL_TEST_ASSUME(strcmp(inputPassword, validPassword) != 0, "Password should not match");
134+
FOSSIL_TEST_ASSUME(inputUsername == validUsername, "Username should match");
135+
FOSSIL_TEST_ASSUME(inputPassword != validPassword, "Password should not match");
135136
}
136137
}
137138
}
@@ -140,19 +141,19 @@ FOSSIL_TEST_CASE(cpp_xbdd_valid_login) {
140141
FOSSIL_TEST_CASE(cpp_xbdd_invalid_login) {
141142
GIVEN("a registered user with valid credentials") {
142143
// Set up the context
143-
const char* validUsername = "user123";
144-
const char* validPassword = "pass456";
144+
std::string validUsername = "user123";
145+
std::string validPassword = "pass456";
145146

146147
WHEN("the user provides incorrect username") {
147148
// Perform the action of user login
148-
const char* inputUsername = "wronguser";
149-
const char* inputPassword = "pass456";
149+
std::string inputUsername = "wronguser";
150+
std::string inputPassword = "pass456";
150151

151152
THEN("the login should fail with an error message") {
152153
// Check the expected outcome
153154
// Simulate login validation
154-
FOSSIL_TEST_ASSUME(strcmp(inputUsername, validUsername) != 0, "Username should not match");
155-
FOSSIL_TEST_ASSUME(strcmp(inputPassword, validPassword) == 0, "Password should match");
155+
FOSSIL_TEST_ASSUME(inputUsername != validUsername, "Username should not match");
156+
FOSSIL_TEST_ASSUME(inputPassword == validPassword, "Password should match");
156157
}
157158
}
158159
}

code/tests/cases/test_mark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ FOSSIL_TEST_CASE(cpp_mark_start_and_stop) {
5050
MARK_BENCHMARK(stop_test);
5151
MARK_START(stop_test);
5252
MARK_STOP(stop_test);
53-
ASSUME_ITS_EQUAL_CSTR(benchmark_stop_test.name, benchmark_stop_test_name.c_str());
53+
ASSUME_ITS_EQUAL_CSTR(std::string(benchmark_stop_test.name), benchmark_stop_test_name);
5454
}
5555

5656
// * * * * * * * * * * * * * * * * * * * * * * * *

code/tests/cases/test_tdd.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* -----------------------------------------------------------------------------
1414
*/
1515
#include <fossil/test/framework.h>
16+
#include <string>
1617

1718
// * * * * * * * * * * * * * * * * * * * * * * * *
1819
// * Fossil Logic Test Utilites
@@ -686,9 +687,9 @@ FOSSIL_TEST_CASE(cpp_assume_run_of_wstr) {
686687
} // end case
687688

688689
FOSSIL_TEST_CASE(cpp_assume_run_of_bstr) {
689-
const char *str1 = (const char *)"Hello";
690-
const char *str2 = (const char *)"Hello";
691-
const char *str3 = (const char *)"World";
690+
std::string str1 = "Hello";
691+
std::string str2 = "Hello";
692+
std::string str3 = "World";
692693

693694
// Test cases
694695
ASSUME_ITS_EQUAL_BSTR(str1, str2);
@@ -697,9 +698,9 @@ FOSSIL_TEST_CASE(cpp_assume_run_of_bstr) {
697698
} // end case
698699

699700
FOSSIL_TEST_CASE(cpp_assume_run_of_cstr) {
700-
const char *str1 = "Hello";
701-
const char *str2 = "Hello";
702-
const char *str3 = "World";
701+
std::string str1 = "Hello";
702+
std::string str2 = "Hello";
703+
std::string str3 = "World";
703704

704705
// Test cases
705706
ASSUME_ITS_EQUAL_CSTR(str1, str2);

0 commit comments

Comments
 (0)