1####################################################### 2# 3# Test readrealarray(), introduce 777 12345 with no other fields 4# 5# The 5xx tests look at the same thing as their corresponding 4xx tests 6# 500-519 are readrealarray, 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 3312345 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 "cnt" int => readrealarray("ary", "$(G.testfile)","NoComment",":",10,1000); 50 "num" int => "3"; 51} 52 53####################################################### 54 55bundle agent check 56{ 57 vars: 58 "idx" slist => getindices("test.ary"); 59 60 classes: 61 "good" and => { 62 strcmp("$(test.num)", "$(test.cnt)"), 63 64 strcmp("$(test.ary[0][0])", "0"), 65 strcmp("$(test.ary[0][1])", "1"), 66 strcmp("$(test.ary[0][2])", "2"), 67 68 strcmp("$(test.ary[12345][0])", "12345"), 69 70 strcmp("$(test.ary[1][0])", "1"), 71 strcmp("$(test.ary[1][1])", "2"), 72 strcmp("$(test.ary[1][2])", "3"), 73 }; 74 75 # Make sure there are no trailing elements 76 "bad" or => { 77 isvariable("test.ary[0][3]"), 78 isvariable("test.ary[12345][1]"), 79 isvariable("test.ary[1][3]"), 80 }; 81 82 "ok" expression => "good&!bad"; 83 84 reports: 85 DEBUG:: 86 "expected $(test.num) entries, saw $(test.cnt)"; 87 88 "saw array indices '$(idx)'"; 89 90 "expected test.ary[0][0] = '0', saw '$(test.ary[0][0])'"; 91 "expected test.ary[0][1] = '1', saw '$(test.ary[0][1])'"; 92 "expected test.ary[0][2] = '2', saw '$(test.ary[0][2])'"; 93 94 "expected test.ary[12345][0] = '12345', saw '$(test.ary[12345][0])'"; 95 96 "expected test.ary[1][0] = '1', saw '$(test.ary[1][0])'"; 97 "expected test.ary[1][1] = '2', saw '$(test.ary[1][1])'"; 98 "expected test.ary[1][2] = '3', saw '$(test.ary[1][2])'"; 99 100 ok:: 101 "$(this.promise_filename) Pass"; 102 103 !ok:: 104 "$(this.promise_filename) FAIL"; 105} 106