Skip to content

Commit

Permalink
Add test for parser
Browse files Browse the repository at this point in the history
  • Loading branch information
titsuki committed Feb 25, 2017
1 parent 810d57b commit a113c6d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions t/07-parse.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use v6;
use Test;
use Algorithm::LibSVM;
use Algorithm::LibSVM::Parameter;
use Algorithm::LibSVM::Problem;
use Algorithm::LibSVM::Model;

subtest {

my \myhash = parse-libsvmformat(q:to/END/);
1 1:0.5 2:0.6
2 1:0.2 2:0.3
END

is myhash[0]<label>, 1;
is myhash[1]<label>, 2;

ok myhash[0]<pairs> ~~ (1 => 0.5, 2 => 0.6);
ok myhash[1]<pairs> ~~ (1 => 0.2, 2 => 0.3);

}, "parse-libsvmformat should parse valid-format input";

dies-ok {

my Pair @test = parse-libsvmformat(q:to/END/).head<pairs>.flat;
1 1;0.5 2:0.5
END

}, "Cannot use ; as a delimiter";

dies-ok {

my Pair @test = parse-libsvmformat(q:to/END/).head<pairs>.flat;
1 1:0.52:0.5
END

}, "Cannot use integer:number:number form";

done-testing;

0 comments on commit a113c6d

Please sign in to comment.