summaryrefslogtreecommitdiff
path: root/tests/features/test_embed.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features/test_embed.zc')
-rw-r--r--tests/features/test_embed.zc57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/features/test_embed.zc b/tests/features/test_embed.zc
new file mode 100644
index 0000000..f6d9468
--- /dev/null
+++ b/tests/features/test_embed.zc
@@ -0,0 +1,57 @@
+
+test "test_embed" {
+ "=> Static File Analyzer";
+
+ var data = embed "std.zc";
+
+ "Target File: 'std.zc'";
+ "File Size: {data.len} bytes";
+ "";
+
+ var lines: I32 = 1;
+ var words: I32 = 0;
+ var sum: U64 = 0;
+ var in_word: bool = 0;
+
+ "Analyzing content...";
+
+ var i: int = 0;
+ while (i < data.len) {
+ var c: char = data.data[i];
+
+ match c {
+ '\n' => {
+ lines++;
+ in_word = 0;
+ }
+
+ ' ', '\t', '\r' => {
+ in_word = 0;
+ }
+
+ _ => {
+ if (!in_word) {
+ words++;
+ in_word = 1;
+ }
+ }
+ }
+
+ var b: U8 = c;
+ sum = sum + b;
+
+ i++;
+ }
+
+ "";
+ "*** Report ***";
+ "Total Lines: {lines}";
+ "Total Words: {words}";
+
+ "Checksum: 0x{sum:X} (Simple Sum)";
+ "Average Byte: {sum / data.len}";
+
+ "";
+ "Analysis successfully completed.";
+
+}