-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#define SDL_MAIN_HANDLED | ||
#include <cbehave/cbehave.h> | ||
|
||
#include <yajl_utils.h> | ||
|
||
FEATURE(string_pair, "String pair") | ||
SCENARIO("String pair") | ||
GIVEN("a string key/value pair") | ||
const char *key = "key"; | ||
const char *value = "value"; | ||
|
||
WHEN("I add the pair") | ||
yajl_gen g = yajl_gen_alloc(NULL); | ||
yajl_gen_map_open(g); | ||
YAJLAddStringPair(g, key, value); | ||
yajl_gen_map_close(g); | ||
const unsigned char *buf; | ||
size_t len; | ||
yajl_gen_get_buf(g, &buf, &len); | ||
AND("I load the document back") | ||
yajl_val node = yajl_tree_parse((const char *)buf, NULL, 0); | ||
|
||
THEN("the loaded value should be the same") | ||
char *loadedValue = YAJLGetStr(node, key); | ||
SHOULD_STR_EQUAL(loadedValue, value); | ||
CFREE(loadedValue); | ||
yajl_tree_free(node); | ||
yajl_gen_clear(g); | ||
yajl_gen_free(g); | ||
SCENARIO_END | ||
FEATURE_END | ||
|
||
CBEHAVE_RUN("YAJL features are:", TEST_FEATURE(string_pair)) |