-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Generate test code in C * add some test code * fix issue with static strings
- Loading branch information
Showing
7 changed files
with
169 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
#include "bosatsu_runtime.h" | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
void assert(_Bool cond, char* message) { | ||
if (!cond) { | ||
printf("%s\n", message); | ||
exit(1); | ||
} | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
BValue s1 = alloc_struct2(alloc_enum0(0), alloc_enum0(1)); | ||
assert(get_variant(get_struct_index(s1, 0)) == 0, "index0 == alloc_enum0"); | ||
assert(get_variant(get_struct_index(s1, 1)) == 1, "index0 == alloc_enum0(1)"); | ||
release_value(s1); | ||
|
||
char* hello = "hello1"; | ||
|
||
BValue v1 = bsts_string_from_utf8_bytes_copy(5, "hello"); | ||
// we can ignore trailing byte string on hello, by taking the front | ||
BValue v2 = bsts_string_from_utf8_bytes_static(5, hello); | ||
assert(bsts_string_equals(v1, v2), "v1 == v2"); | ||
assert(bsts_string_equals(v1, v1), "v1 == v1"); | ||
assert(bsts_string_equals(v2, v2), "v2 == v2"); | ||
release_value(v1); | ||
release_value(v2); | ||
|
||
printf("success\n"); | ||
return 0; | ||
} |
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