Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
mxq
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
20
Pull requests
3
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
add-gpu-alloc-debug
helper
manpages
mysql
web
.gitignore
.vimrc
Doxyfile
LICENSE
Makefile
README.md
keywordset.c
keywordset.h
mx_flock.c
mx_flock.h
mx_getopt.c
mx_getopt.h
mx_log.c
mx_log.h
mx_mysql.c
mx_mysql.h
mx_proc.c
mx_proc.h
mx_util.c
mx_util.h
mxq.h
mxq_daemon.c
mxq_daemon.h
mxq_group.c
mxq_group.h
mxq_job.c
mxq_job.h
mxq_log.c
mxq_reaper.c
mxqadmin.c
mxqd.c
mxqd.h
mxqd_control.c
mxqd_control.h
mxqdctl-hostconfig.sh
mxqdump.c
mxqkill.c
mxqps.c
mxqset.c
mxqsub.c
os-release
parser.y
ppidcache.c
ppidcache.h
test_keywordset.c
test_mx_log.c
test_mx_mysql.c
test_mx_util.c
test_mxqd_control.c
test_parser.c
xmalloc.h
Breadcrumbs
mxq
/
test_keywordset.c
Blame
Blame
Latest commit
History
History
70 lines (58 loc) · 2.34 KB
Breadcrumbs
mxq
/
test_keywordset.c
Top
File metadata and controls
Code
Blame
70 lines (58 loc) · 2.34 KB
Raw
#include <assert.h> #include <string.h> #include "keywordset.h" #include <stdlib.h> #include <stdio.h> static void test_new(char *init, char *expect) { struct keywordset *kws = keywordset_new(init); char *s = keywordset_get(kws); if (strcmp(s, expect)) fprintf(stderr, "FAIL: new from '%s' got '%s' expected '%s'\n", init, s, expect); \ free(s); keywordset_free(kws); } static void test_update(struct keywordset *kws, char *update, char *expect) { char *init = keywordset_get(kws); keywordset_update(kws, update); char *s = keywordset_get(kws); if (strcmp(s, expect)) fprintf(stderr, "FAIL: update '%s' with '%s' got '%s' expected '%s'\n", init, update, s, expect); free(s); free(init); } static void test_add(struct keywordset *kws, char *add, char *expect) { char *init = keywordset_get(kws); keywordset_add(kws, add); char *s = keywordset_get(kws); if (strcmp(s, expect)) fprintf(stderr, "FAIL: add '%s' with '%s' got '%s' expected '%s'\n", init, add, s, expect); free(s); free(init); } int main() { test_new(NULL, ""); test_new("", ""); test_new("h7 h8 h9 h1 h2 h3", "h1 h2 h3 h7 h8 h9"); test_new(" h7\th8 h9 h1 h2 h3 \n", "h1 h2 h3 h7 h8 h9"); struct keywordset *kws = keywordset_new("a b c"); test_update(kws, "d e f", "d e f"); test_update(kws, "+g +h +i", "d e f g h i"); test_update(kws, "-e -h", "d f g i"); test_update(kws, "-i +x", "d f g x"); test_update(kws, "-x +m +n -n x y +a", "a m y"); test_update(kws, "-x +x", "a m x y"); test_update(kws, "+z -z", "a m x y"); keywordset_purge(kws); test_update(kws, "", ""); keywordset_purge(kws); test_update(kws, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); keywordset_free(kws); kws = keywordset_new("abcdef"); test_update(kws, "+ab", "ab abcdef"); test_update(kws, "+abcdefgh", "ab abcdef abcdefgh"); keywordset_free(kws); kws = keywordset_new("x x x"); test_add(kws, "a b c", "a b c x"); test_add(kws, "-x +y", "+y -x a b c x"); keywordset_free(kws); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
You can’t perform that action at this time.