diff options
Diffstat (limited to 'src/mustach/test6')
-rw-r--r-- | src/mustach/test6/.gitignore | 4 | ||||
-rw-r--r-- | src/mustach/test6/Makefile | 15 | ||||
-rw-r--r-- | src/mustach/test6/json | 23 | ||||
-rw-r--r-- | src/mustach/test6/must | 43 | ||||
-rw-r--r-- | src/mustach/test6/resu.ref | 147 | ||||
-rw-r--r-- | src/mustach/test6/test-custom-write.c | 145 |
6 files changed, 0 insertions, 377 deletions
diff --git a/src/mustach/test6/.gitignore b/src/mustach/test6/.gitignore deleted file mode 100644 index 62f4d919..00000000 --- a/src/mustach/test6/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -resu.last -vg.last -test-custom-write -!test-custom-write.c diff --git a/src/mustach/test6/Makefile b/src/mustach/test6/Makefile deleted file mode 100644 index b8a63375..00000000 --- a/src/mustach/test6/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -.PHONY: test clean - -test-custom-write: test-custom-write.c ../mustach-json-c.h ../mustach-json-c.c ../mustach.h ../mustach.c - @echo building test-custom-write - $(CC) $(CFLAGS) -g -o test-custom-write test-custom-write.c ../mustach.c ../mustach-json-c.c -ljson-c - -test: test-custom-write - @echo starting test - @valgrind ./test-custom-write json -U must -l must -x must > resu.last 2> vg.last - @sed -i 's:^==[0-9]*== ::' vg.last - @diff resu.ref resu.last && echo "result ok" || echo "ERROR! Result differs" - -clean: - rm -f resu.last test-custom-write - diff --git a/src/mustach/test6/json b/src/mustach/test6/json deleted file mode 100644 index 5b2e3d83..00000000 --- a/src/mustach/test6/json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "Chris", - "value": 10000, - "taxed_value": 6000, - "in_ca": true, - "person": false, - "repo": [ - { "name": "resque", "who": [ { "committer": "joe" }, { "reviewer": "avrel" }, { "committer": "william" } ] }, - { "name": "hub", "who": [ { "committer": "jack" }, { "reviewer": "avrel" }, { "committer": "greg" } ] }, - { "name": "rip", "who": [ { "reviewer": "joe" }, { "reviewer": "jack" }, { "committer": "greg" } ] } - ], - "person?": { "name": "Jon" }, - "special": "----{{extra}}----", - "extra": 3.14159, - "#sharp": "#", - "!bang": "!", - "/slash": "/", - "^circ": "^", - "=equal": "=", - ":colon": ":", - ">greater": ">", - "~tilde": "~" -} diff --git a/src/mustach/test6/must b/src/mustach/test6/must deleted file mode 100644 index 723f966c..00000000 --- a/src/mustach/test6/must +++ /dev/null @@ -1,43 +0,0 @@ -Hello {{name}} -You have just won {{value}} dollars! -{{#in_ca}} -Well, {{taxed_value}} dollars, after taxes. -{{/in_ca}} -Shown. -{{#person}} - Never shown! -{{/person}} -{{^person}} - No person -{{/person}} - -{{#repo}} - <b>{{name}}</b> reviewers:{{#who}} {{reviewer}}{{/who}} committers:{{#who}} {{committer}}{{/who}} -{{/repo}} - -{{#person?}} - Hi {{name}}! -{{/person?}} - -{{=%(% %)%=}} -===================================== -%(%! gros commentaire %)% -%(%#repo%)% - <b>%(%name%)%</b> reviewers:%(%#who%)% %(%reviewer%)%%(%/who%)% committers:%(%#who%)% %(%committer%)%%(%/who%)% -%(%/repo%)% -===================================== -%(%={{ }}=%)% -ggggggggg -{{> special}} -jjjjjjjjj -end - -{{:#sharp}} -{{:!bang}} -{{:~tilde}} -{{:/~0tilde}} -{{:/~1slash}} see json pointers IETF RFC 6901 -{{:^circ}} -{{:\=equal}} -{{::colon}} -{{:>greater}} diff --git a/src/mustach/test6/resu.ref b/src/mustach/test6/resu.ref deleted file mode 100644 index 345d3aef..00000000 --- a/src/mustach/test6/resu.ref +++ /dev/null @@ -1,147 +0,0 @@ -HELLO CHRIS -YOU HAVE JUST WON 10000 DOLLARS! - -WELL, 6000 DOLLARS, AFTER TAXES. - -SHOWN. - - - NO PERSON - - - - <B>RESQUE</B> REVIEWERS: AVREL COMMITTERS: JOE WILLIAM - - <B>HUB</B> REVIEWERS: AVREL COMMITTERS: JACK GREG - - <B>RIP</B> REVIEWERS: JOE JACK COMMITTERS: GREG - - - - HI JON! - - - -===================================== - - - <B>RESQUE</B> REVIEWERS: AVREL COMMITTERS: JOE WILLIAM - - <B>HUB</B> REVIEWERS: AVREL COMMITTERS: JACK GREG - - <B>RIP</B> REVIEWERS: JOE JACK COMMITTERS: GREG - -===================================== - -GGGGGGGGG -----3.14159---- -JJJJJJJJJ -END - -# -! -~ -~ -/ SEE JSON POINTERS IETF RFC 6901 -^ -= -: -> -hello chris -you have just won 10000 dollars! - -well, 6000 dollars, after taxes. - -shown. - - - no person - - - - <b>resque</b> reviewers: avrel committers: joe william - - <b>hub</b> reviewers: avrel committers: jack greg - - <b>rip</b> reviewers: joe jack committers: greg - - - - hi jon! - - - -===================================== - - - <b>resque</b> reviewers: avrel committers: joe william - - <b>hub</b> reviewers: avrel committers: jack greg - - <b>rip</b> reviewers: joe jack committers: greg - -===================================== - -ggggggggg -----3.14159---- -jjjjjjjjj -end - -# -! -~ -~ -/ see json pointers ietf rfc 6901 -^ -= -: -> -Hello Chris -You have just won 10000 dollars! - -Well, 6000 dollars, after taxes. - -Shown. - - - No person - - - - <b>resque</b> reviewers: avrel committers: joe william - - <b>hub</b> reviewers: avrel committers: jack greg - - <b>rip</b> reviewers: joe jack committers: greg - - - - Hi Jon! - - - -===================================== - - - <b>resque</b> reviewers: avrel committers: joe william - - <b>hub</b> reviewers: avrel committers: jack greg - - <b>rip</b> reviewers: joe jack committers: greg - -===================================== - -ggggggggg -----3.14159---- -jjjjjjjjj -end - -# -! -~ -~ -/ see json pointers IETF RFC 6901 -^ -= -: -> diff --git a/src/mustach/test6/test-custom-write.c b/src/mustach/test6/test-custom-write.c deleted file mode 100644 index cc50a47c..00000000 --- a/src/mustach/test6/test-custom-write.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - Author: José Bollo <jobol@nonadev.net> - Author: José Bollo <jose.bollo@iot.bzh> - - https://gitlab.com/jobol/mustach - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#define _GNU_SOURCE - -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <sys/stat.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <libgen.h> - -#include "../mustach-json-c.h" - -static const size_t BLOCKSIZE = 8192; - -static char *readfile(const char *filename) -{ - int f; - struct stat s; - char *result; - size_t size, pos; - ssize_t rc; - - result = NULL; - if (filename[0] == '-' && filename[1] == 0) - f = dup(0); - else - f = open(filename, O_RDONLY); - if (f < 0) { - fprintf(stderr, "Can't open file: %s\n", filename); - exit(1); - } - - fstat(f, &s); - switch (s.st_mode & S_IFMT) { - case S_IFREG: - size = s.st_size; - break; - case S_IFSOCK: - case S_IFIFO: - size = BLOCKSIZE; - break; - default: - fprintf(stderr, "Bad file: %s\n", filename); - exit(1); - } - - pos = 0; - result = malloc(size + 1); - do { - if (result == NULL) { - fprintf(stderr, "Out of memory\n"); - exit(1); - } - rc = read(f, &result[pos], (size - pos) + 1); - if (rc < 0) { - fprintf(stderr, "Error while reading %s\n", filename); - exit(1); - } - if (rc > 0) { - pos += (size_t)rc; - if (pos > size) { - size = pos + BLOCKSIZE; - result = realloc(result, size + 1); - } - } - } while(rc > 0); - - close(f); - result[pos] = 0; - return result; -} - -enum { None, Upper, Lower } mode = None; - -int uwrite(void *closure, const char *buffer, size_t size) -{ - switch(mode) { - case None: - fwrite(buffer, size, 1, stdout); - break; - case Upper: - while(size--) - fputc(toupper(*buffer++), stdout); - break; - case Lower: - while(size--) - fputc(tolower(*buffer++), stdout); - break; - } - return 0; -} - -int main(int ac, char **av) -{ - struct json_object *o; - char *t; - char *prog = *av; - int s; - - if (*++av) { - o = json_object_from_file(av[0]); - if (o == NULL) { - fprintf(stderr, "Aborted: null json (file %s)\n", av[0]); - exit(1); - } - while(*++av) { - if (!strcmp(*av, "-U")) - mode = Upper; - else if (!strcmp(*av, "-l")) - mode = Lower; - else if (!strcmp(*av, "-x")) - mode = None; - else { - t = readfile(*av); - s = umustach_json_c(t, o, uwrite, NULL); - if (s != 0) - fprintf(stderr, "Template error %d\n", s); - free(t); - } - } - json_object_put(o); - } - return 0; -} - |