-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
random_float, minor bugfixes/improvements, debug/release build comman…
…ds, todo * Modified token_gen.nvgt to use bitwise flags instead of a rigid enum. * settings.nvgt can now be more easily extended as the list of available formats is no longer hardcoded. Adds test for settings include, though should be made to execute faster. * The test runner now allows test cases to safely change the current working directory. * Fix a couple of const qualifiers in ini.nvgt. * It is now possible to specify prebuild and postbuild commands based on debug/release builds. * Add random_float function. * Update Todo (nonconclusive).
- Loading branch information
Showing
10 changed files
with
103 additions
and
50 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
14 changes: 7 additions & 7 deletions
14
...rc/references/include/Token Generation (token_gen.nvgt)/Enums/token_gen_flag.md
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,9 +1,9 @@ | ||
# token_gen_flag | ||
This enum holds various constants that can be passed to the mode parameter in order to change how tokens are generated in the `generate_token` function. | ||
This enum holds various constants that can be passed to the mode parameter of the generate_token function in order to control what characters appear in results. | ||
|
||
* token_gen_flag_all: Uses all characters, numbers and symbols, see below. | ||
* token_gen_flag_characters: Uses only characters, a-zA-Z | ||
* token_gen_flag_numbers: Uses only numbers, 0-9 | ||
* token_gen_flag_symbols: Uses only symbols, \`\~\!\@\#\$\%\^\&\*\(\)\_\+\=\-\[\]\{\}\/\.\,\;\:\|\?\>\< | ||
* token_gen_flag_numbers_symbols: Uses numbers and symbols. | ||
* token_gen_flag_characters_symbols: Uses characters and symbols. | ||
* TOKEN_CHARACTERS = 1: Allows for characters, a-zA-Z | ||
* TOKEN_NUMBERS = 2: Allows for numbers, 0-9 | ||
* TOKEN_SYMBOLS = 4: Uses only symbols, \`\~\!\@\#\$\%\^\&\*\(\)\_\+\=\-\[\]\{\}\/\.\,\;\:\|\?\>\< | ||
|
||
## Remarks: | ||
These are flags that should be combined together using the bitwise OR operator. To generate a token containing characters and symbols, for example, you would pass `TOKEN_CHARACTERS | TOKEN_NUMBERS | TOKEN_SYMBOLS` to the mode argument of generate_token. The default flags are TOKEN_CHARACTERS | TOKEN_NUMBERS. |
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,39 @@ | ||
#include "settings.nvgt" | ||
#include "token_gen.nvgt" | ||
|
||
// We run this test multiple times, once per format. | ||
void evaluate_format(string format, settings@ s = null) { | ||
if (@s == null) @s = settings(); // Allow already existing objects to test whether a settings object can close one format and open another. | ||
assert(s.setup("NVGTTesting", "testing_framework", true, format)); | ||
uint key_count = 10; | ||
string[] strings(key_count); | ||
double[] numbers(key_count); | ||
for (uint i = 0; i < key_count; i++) { | ||
strings[i] = generate_token(i * 10); | ||
assert(s.write_string("s" + i, strings[i])); | ||
assert(s.read_string("s" + i) == strings[i]); | ||
numbers[i] = random(i * 2, i * 10) + random_float(); | ||
assert(s.write_number("n" + i, numbers[i])); | ||
assert(s.read_number("n" + i) == numbers[i]); | ||
} | ||
assert(s.close()); | ||
assert(s.setup("NVGTTesting", "testing_framework", true, format)); | ||
for (uint i = 0; i < key_count; i++) { | ||
assert(s.read_string("s" + i) == strings[i]); | ||
assert(s.read_number("n" + i) == numbers[i]); | ||
} | ||
assert(s.remove_product()); | ||
} | ||
|
||
void test_settings_include() { | ||
directory_delete("NVGTTesting"); // Start from scratch. | ||
settings s; | ||
assert(s.setup("NVGTTesting", "testing_framework", true)); | ||
assert(!s.has_other_products()); | ||
evaluate_format("ini"); | ||
evaluate_format("ini", s); | ||
evaluate_format("json"); | ||
evaluate_format("json", s); | ||
evaluate_format("nvgt"); | ||
evaluate_format("nvgt", s); | ||
} |
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