EqualBasis: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Syntax) |
Keine Bearbeitungszusammenfassung |
||
Zeile 12: | Zeile 12: | ||
===Beispiele=== | ===Beispiele=== | ||
equalBasis('[[1,1,0],[0,1,1]]', '[[1,1,0],[0,1,1]]', '3') --> | equalBasis('[[1,1,0],[0,1,1]]', '[[1,1,0],[0,1,1]]', '3') --> | ||
====JUnit Tests==== | |||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | |||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | |||
@BeforeClass | |||
public static void beforeTest() { | |||
//set(vector(1,2,3),vector(3,3,3)) | |||
equalBasisFillInVariableMap.put(1, OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
//set(vector(2,5,6),vector(3,3,3)) | |||
equalBasisFillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>2</OMI><OMI>5</OMI><OMI>6</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
//set(vector(1,2,3),vector(3,3,3)) | |||
equalBasisExerciseVariableMap.put("a", OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
//set(vector(2,5,6),vector(3,3,3)) | |||
equalBasisExerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>2</OMI><OMI>5</OMI><OMI>6</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>")); | |||
} | |||
@Test | |||
public void testEqualBasis1() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('{vector(1,1,0);vector(0,1,1)}', 'set(vector(1,1,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasis2() { | |||
assertTrue(!Evaluator.getBooleanResult("equalBasis('set(vector(1,1,1),vector(0,1,1))', 'set(vector(1,1,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasis3() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('{vector(1,1);vector(0,1)}', '{vector(1,1);vector(0,1)}', '2')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasis4() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1),vector(0,1))', '{vector(1,1);vector(0,1)}', '2')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasis5() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1,0),vector(0,1,1))', '{vector(1,1,0);vector(0,1,1)}', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasis6() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1,0),vector(0,1,1))', 'set(vector(3,3,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasisWithInput1() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('[pos=1]', '[pos=1]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasisWithInput2() { | |||
assertTrue(!Evaluator.getBooleanResult("equalBasis('[pos=1]', '[pos=2]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasisWithVariables1() { | |||
assertTrue(Evaluator.getBooleanResult("equalBasis('[var=a]', '[var=a]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test | |||
public void testEqualBasisWithVariables2() { | |||
assertTrue(!Evaluator.getBooleanResult("equalBasis('[var=a]', '[var=b]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap)); | |||
} | |||
@Test(expected=FunctionInvalidArgumentTypeException.class) | |||
public void testEqualBasisWithWrongInputCharacterAsThirdParameter() { | |||
Evaluator.getBooleanResult("equalBasis('(vector(QQ,(1,1,0)),vector(QQ,(0,1,1)))', '(vector(QQ,(3,3,0)),vector(QQ,(0,1,1)))', 'c')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=FunctionInvalidArgumentTypeException.class) | |||
public void testEqualBasisWithWrongInputToManyCommas() { | |||
Evaluator.getBooleanResult("equalBasis('(vector(QQ,,(1,1,,0)),vector(QQ,(0,1,1)))', '(vector(QQ,(3,3,0)),vector(QQ,(0,1,1)))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=ParserException.class) | |||
public void TestEqualBasisWithONECharacter() { | |||
Evaluator.getBooleanResult("equalBasis(ab, ab, ab)", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=FunctionInvalidArgumentTypeException.class) | |||
public void testEqualBasisWithEmptyStringArguments() { | |||
Evaluator.getBooleanResult("equalBasis('', '', '')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=FunctionInvalidNumberOfArgumentsException.class) | |||
public void testEqualBasisWithEmptyArgument() { | |||
Evaluator.getBooleanResult("equalBasis()", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=UndefinedExerciseVariableException.class) | |||
public void testEqualBasisWithoutExerciseVariable() { | |||
Evaluator.getBooleanResult("equalBasis([var=j], [var=j], [var=j])", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
@Test(expected=UndefinedFillInVariableException.class) | |||
public void testEqualBasisWithoutInput() { | |||
Evaluator.getBooleanResult("equalBasis([pos=42], [pos=42], [pos=42])", equalBasisExerciseVariableMap, equalBasisFillInVariableMap); | |||
fail(); | |||
} | |||
</syntaxhighlight> | |||
===Hinweise=== | ===Hinweise=== |
Version vom 18. September 2017, 11:02 Uhr
Beschreibung
Syntax
equalBasis(String vector, String vector, String dimension)
Parameter
Return Value
- Gibt einen boolean zurück
Beispiele
equalBasis('[[1,1,0],[0,1,1]]', '[[1,1,0],[0,1,1]]', '3') -->
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
//set(vector(1,2,3),vector(3,3,3))
equalBasisFillInVariableMap.put(1, OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
//set(vector(2,5,6),vector(3,3,3))
equalBasisFillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>2</OMI><OMI>5</OMI><OMI>6</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
//set(vector(1,2,3),vector(3,3,3))
equalBasisExerciseVariableMap.put("a", OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
//set(vector(2,5,6),vector(3,3,3))
equalBasisExerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMA><OMS cd='list1' name='list'/><OMA><OMS cd='linalg2' name='vector'/><OMI>2</OMI><OMI>5</OMI><OMI>6</OMI></OMA><OMA><OMS cd='linalg2' name='vector'/><OMI>3</OMI><OMI>3</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"));
}
@Test
public void testEqualBasis1() {
assertTrue(Evaluator.getBooleanResult("equalBasis('{vector(1,1,0);vector(0,1,1)}', 'set(vector(1,1,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasis2() {
assertTrue(!Evaluator.getBooleanResult("equalBasis('set(vector(1,1,1),vector(0,1,1))', 'set(vector(1,1,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasis3() {
assertTrue(Evaluator.getBooleanResult("equalBasis('{vector(1,1);vector(0,1)}', '{vector(1,1);vector(0,1)}', '2')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasis4() {
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1),vector(0,1))', '{vector(1,1);vector(0,1)}', '2')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasis5() {
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1,0),vector(0,1,1))', '{vector(1,1,0);vector(0,1,1)}', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasis6() {
assertTrue(Evaluator.getBooleanResult("equalBasis('set(vector(1,1,0),vector(0,1,1))', 'set(vector(3,3,0),vector(0,1,1))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasisWithInput1() {
assertTrue(Evaluator.getBooleanResult("equalBasis('[pos=1]', '[pos=1]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasisWithInput2() {
assertTrue(!Evaluator.getBooleanResult("equalBasis('[pos=1]', '[pos=2]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasisWithVariables1() {
assertTrue(Evaluator.getBooleanResult("equalBasis('[var=a]', '[var=a]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test
public void testEqualBasisWithVariables2() {
assertTrue(!Evaluator.getBooleanResult("equalBasis('[var=a]', '[var=b]', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap));
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testEqualBasisWithWrongInputCharacterAsThirdParameter() {
Evaluator.getBooleanResult("equalBasis('(vector(QQ,(1,1,0)),vector(QQ,(0,1,1)))', '(vector(QQ,(3,3,0)),vector(QQ,(0,1,1)))', 'c')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testEqualBasisWithWrongInputToManyCommas() {
Evaluator.getBooleanResult("equalBasis('(vector(QQ,,(1,1,,0)),vector(QQ,(0,1,1)))', '(vector(QQ,(3,3,0)),vector(QQ,(0,1,1)))', '3')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=ParserException.class)
public void TestEqualBasisWithONECharacter() {
Evaluator.getBooleanResult("equalBasis(ab, ab, ab)", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testEqualBasisWithEmptyStringArguments() {
Evaluator.getBooleanResult("equalBasis('', '', '')", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidNumberOfArgumentsException.class)
public void testEqualBasisWithEmptyArgument() {
Evaluator.getBooleanResult("equalBasis()", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testEqualBasisWithoutExerciseVariable() {
Evaluator.getBooleanResult("equalBasis([var=j], [var=j], [var=j])", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}
@Test(expected=UndefinedFillInVariableException.class)
public void testEqualBasisWithoutInput() {
Evaluator.getBooleanResult("equalBasis([pos=42], [pos=42], [pos=42])", equalBasisExerciseVariableMap, equalBasisFillInVariableMap);
fail();
}