1####################################################### 2# 3# Test parseintarray(), simple 4# 5# The 5xx tests look at the same thing as their corresponding 4xx tests 6# 500-519 are readintarray, 520-539 test the same things for parseintarray 7# 8####################################################### 9 10body common control 11{ 12 inputs => { "../../default.cf.sub" }; 13 bundlesequence => { default("$(this.promise_filename)") }; 14 version => "1.0"; 15} 16 17bundle agent init 18{ 19 files: 20 "$(G.testfile)" 21 delete => init_delete; 22 23 "$(G.testfile)" 24 create => "true", 25 edit_line => init_fill_in; 26} 27 28bundle edit_line init_fill_in 29{ 30 insert_lines: 31 32 "0:1:2 33999:888:777:666 341:2:3"; 35 36} 37 38body delete init_delete 39{ 40 dirlinks => "delete"; 41 rmdirs => "true"; 42} 43 44####################################################### 45 46bundle agent test 47{ 48 vars: 49 "teststr" string => readfile("$(G.testfile)",1000); 50 "cnt" int => parseintarray("ary", "$(teststr)","NoComment",":",10,1000); 51 "num" int => "3"; 52} 53 54####################################################### 55 56bundle agent check 57{ 58 vars: 59 "idx" slist => getindices("test.ary"); 60 61 classes: 62 "good" and => { 63 strcmp("$(test.num)", "$(test.cnt)"), 64 65 strcmp("$(test.ary[0][0])", "0"), 66 strcmp("$(test.ary[0][1])", "1"), 67 strcmp("$(test.ary[0][2])", "2"), 68 69 strcmp("$(test.ary[999][0])", "999"), 70 strcmp("$(test.ary[999][1])", "888"), 71 strcmp("$(test.ary[999][2])", "777"), 72 strcmp("$(test.ary[999][3])", "666"), 73 74 strcmp("$(test.ary[1][0])", "1"), 75 strcmp("$(test.ary[1][1])", "2"), 76 strcmp("$(test.ary[1][2])", "3"), 77 }; 78 79 # Make sure there are no trailing elements 80 "bad" or => { 81 isvariable("test.ary[0][3]"), 82 isvariable("test.ary[999][4]"), 83 isvariable("test.ary[1][3]"), 84 }; 85 86 "ok" expression => "good&!bad"; 87 88 reports: 89 DEBUG:: 90 "expected $(test.num) entries, saw $(test.cnt)"; 91 92 "saw array indices '$(idx)'"; 93 94 "expected test.ary[0][0] = '0', saw '$(test.ary[0][0])'"; 95 "expected test.ary[0][1] = '1', saw '$(test.ary[0][1])'"; 96 "expected test.ary[0][2] = '2', saw '$(test.ary[0][2])'"; 97 98 "expected test.ary[999][0] = '999', saw '$(test.ary[999][0])'"; 99 "expected test.ary[999][1] = '888', saw '$(test.ary[999][1])'"; 100 "expected test.ary[999][2] = '777', saw '$(test.ary[999][2])'"; 101 "expected test.ary[999][3] = '999', saw '$(test.ary[999][3])'"; 102 103 "expected test.ary[1][0] = '1', saw '$(test.ary[1][0])'"; 104 "expected test.ary[1][1] = '2', saw '$(test.ary[1][1])'"; 105 "expected test.ary[1][2] = '3', saw '$(test.ary[1][2])'"; 106 107 ok:: 108 "$(this.promise_filename) Pass"; 109 110 !ok:: 111 "$(this.promise_filename) FAIL"; 112} 113