Commit ff3d7eca authored by Alexander.Trofimov's avatar Alexander.Trofimov

add unit-tests for COUNTIFS function

parent 5d619c8f
...@@ -2244,7 +2244,64 @@ $( function () { ...@@ -2244,7 +2244,64 @@ $( function () {
strictEqual( oParser.calculate().getValue(), 3 ); strictEqual( oParser.calculate().getValue(), 3 );
} ); } );
test( "Test: \"COUNTIF\"", function () { test( "Test: \"COUNTIFS\"", function () {
ws.getRange2( "A15" ).setValue( "Yes" );
ws.getRange2( "A16" ).setValue( "Yes" );
ws.getRange2( "A17" ).setValue( "Yes" );
ws.getRange2( "A18" ).setValue( "No" );
ws.getRange2( "B15" ).setValue( "No" );
ws.getRange2( "B16" ).setValue( "Yes" );
ws.getRange2( "B17" ).setValue( "Yes" );
ws.getRange2( "B18" ).setValue( "Yes" );
ws.getRange2( "C15" ).setValue( "No" );
ws.getRange2( "C16" ).setValue( "No" );
ws.getRange2( "C17" ).setValue( "Yes" );
ws.getRange2( "C18" ).setValue( "Yes" );
oParser = new parserFormula( "COUNTIFS(A15:C15,\"=Yes\")", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "COUNTIFS(A15:A18,\"=Yes\",B15:B18,\"=Yes\")", "B1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
oParser = new parserFormula( "COUNTIFS(A18:C18,\"=Yes\",A16:C16,\"=Yes\")", "C1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
ws.getRange2( "D15" ).setValue( "1" );
ws.getRange2( "D16" ).setValue( "2" );
ws.getRange2( "D17" ).setValue( "3" );
ws.getRange2( "D18" ).setValue( "4" );
ws.getRange2( "D19" ).setValue( "5" );
ws.getRange2( "D20" ).setValue( "6" );
ws.getRange2( "E15" ).setValue( "5/1/2011" );
ws.getRange2( "E16" ).setValue( "5/2/2011" );
ws.getRange2( "E17" ).setValue( "5/3/2011" );
ws.getRange2( "E18" ).setValue( "5/4/2011" );
ws.getRange2( "E19" ).setValue( "5/5/2011" );
ws.getRange2( "E20" ).setValue( "5/6/2011" );
oParser = new parserFormula( "COUNTIFS(D15:D20,\"<6\",D15:D20,\">1\")", "D1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 4 );
oParser = new parserFormula( "COUNTIFS(D15:D20,\"<5\",E15:E20,\"<5/3/2011\")", "E1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
oParser = new parserFormula( "COUNTIFS(D15:D20,\"<\" & D19,E15:E20,\"<\" & E17)", "E1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
} );
test( "Test: \"COUNTIFS\"", function () {
ws.getRange2( "A7" ).setValue( "3" ); ws.getRange2( "A7" ).setValue( "3" );
ws.getRange2( "B7" ).setValue( "10" ); ws.getRange2( "B7" ).setValue( "10" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment