summaryrefslogtreecommitdiff
path: root/t/42-dbobject.t
blob: ccb94bc99c03ff2ebd981f3963f98139cf48a468 (plain)
  1. use LedgerSMB::DBObject;
  2. use Test::More tests => 20;
  3. # Array parsing tests
  4. my $test = '{test,"test2\"\",",test3,"test4"}';
  5. my @vals = ('test', 'test2"",', 'test3', 'test4');
  6. my $passes = 0;
  7. for (LedgerSMB::DBObject->_parse_array($test)){
  8. is($_, shift @vals, "pass $pass, array parse test");
  9. }
  10. my $test2 = '{{1,1,1,1},{1,2,2,2},{1,3,3,4}}';
  11. my @test_arry2_c = ( [1,1,1,1], [1,2,2,2], [1,3,3,4]);
  12. my @test_arry2 = LedgerSMB::DBObject->_parse_array($test2);
  13. is(scalar @test_arry2, 3, 'Compount array with proper element count');
  14. is(scalar @{$test_arry2[0]}, 4, 'Subarray 1 has correct element count');
  15. is(scalar @{$test_arry2[1]}, 4, 'Subarray 2 has correct element count');
  16. is(scalar @{$test_arry2[2]}, 4, 'Subarray 3 has correct element count');
  17. for my $outer(0 .. 2){
  18. for my $inner(0 .. 3) {
  19. is ($test_arry2[$outer]->[$inner], $test_arry2_c[$outer]->[$inner],
  20. "Compound array $outer/$inner correct");
  21. }
  22. }