--- var_test.c 2002/03/07 09:14:05 1.42
+++ var_test.c 2002/03/07 12:11:09 1.43
@@ -295,6 +295,43 @@
}
free(tmp);
}
+
+ fprintf(stderr, "Test case: formatting \"foo\"\n");
+ if ((rc = var_format(var, &tmp, 1, "foo")) != VAR_OK) {
+ var_strerror(var, rc, &err);
+ fprintf(stderr, "Formatting failed: %s (%d)\n", err, rc);
+ return 1;
+ }
+ if (strcmp(tmp, "foo") != 0) {
+ fprintf(stderr, "Formatting failed: expected \"foo\", got \"%s\"\n", tmp);
+ return 1;
+ }
+ free(tmp);
+
+ fprintf(stderr, "Test case: formatting \"foo<bar><123><x>\"\n");
+ if ((rc = var_format(var, &tmp, 1, "foo<%s><%d><%c>", "bar", 123, 'x')) != VAR_OK) {
+ var_strerror(var, rc, &err);
+ fprintf(stderr, "Formatting failed: %s (%d)\n", err, rc);
+ return 1;
+ }
+ if (strcmp(tmp, "foo<bar><123><x>") != 0) {
+ fprintf(stderr, "Formatting failed: expected \"foo<bar><123><x>\", got \"%s\"\n", tmp);
+ return 1;
+ }
+ free(tmp);
+
+ fprintf(stderr, "Test case: formatting \"foo${ARRAY[1]}bar\"\n");
+ if ((rc = var_format(var, &tmp, 1, "foo${ARRAY[%d]}bar", 1)) != VAR_OK) {
+ var_strerror(var, rc, &err);
+ fprintf(stderr, "Formatting failed: %s (%d)\n", err, rc);
+ return 1;
+ }
+ if (strcmp(tmp, "fooentry1bar") != 0) {
+ fprintf(stderr, "Formatting failed: expected \"fooentry1bar\", got \"%s\"\n", tmp);
+ return 1;
+ }
+ free(tmp);
+
var_destroy(var);
return 0;
}
|