summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/SmokeTest.mc41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/SmokeTest.mc b/test/SmokeTest.mc
new file mode 100644
index 0000000..60e98c1
--- /dev/null
+++ b/test/SmokeTest.mc
@@ -0,0 +1,41 @@
+// Author: cirakg & claude ai
+// Summary: Smoke test proving the unit-test pipeline works end to end.
+//
+// SmokeTest: proves the unit-test pipeline works end to end: compile with
+// --unit-test, run in the headless simulator, parse the results with
+// tools/ciq_test_report.py. The real test suites start with milestone M2.
+
+import Toybox.Lang;
+import Toybox.Test;
+
+// ASCII codes of the characters a version may contain.
+const ASCII_DOT = 46;
+const ASCII_ZERO = 48;
+const ASCII_NINE = 57;
+
+// AppInfo.VERSION must look like MAJOR.MINOR.PATCH: three non-empty runs of
+// digits separated by two dots, nothing else.
+(:test)
+function smokeVersionIsSemver(logger as Test.Logger) as Boolean {
+ var dots = 0;
+ var digitsInPart = 0;
+ var chars = AppInfo.VERSION.toCharArray();
+ for (var i = 0; i < chars.size(); i++) {
+ var code = chars[i].toNumber();
+ if (code == ASCII_DOT) {
+ if (digitsInPart == 0) {
+ logger.error("empty part in version " + AppInfo.VERSION);
+ return false;
+ }
+ dots++;
+ digitsInPart = 0;
+ } else if (code >= ASCII_ZERO && code <= ASCII_NINE) {
+ digitsInPart++;
+ } else {
+ logger.error("unexpected character in version " + AppInfo.VERSION);
+ return false;
+ }
+ }
+ logger.debug("version " + AppInfo.VERSION);
+ return dots == 2 && digitsInPart > 0;
+}