-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor compareRight added tests for Compare method
- Loading branch information
1 parent
0150451
commit a3addb9
Showing
3 changed files
with
75 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.orm.util; | ||
|
||
import com.orm.util.NamingHelper; | ||
|
||
import org.junit.Test; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
|
||
public class NamingHelperTest { | ||
@Test | ||
public void testToSQLNameCaseConversion() throws Exception { | ||
assertToSqlNameEquals("TESTLOWERCASE", "testlowercase"); | ||
assertToSqlNameEquals("TESTUPPERCASE", "TESTUPPERCASE"); | ||
} | ||
|
||
@Test | ||
public void testToSQLNameUnderscore() { | ||
assertToSqlNameEquals("TEST_UNDERSCORE", "testUnderscore"); | ||
assertToSqlNameEquals("AB_CD", "AbCd"); | ||
assertToSqlNameEquals("AB_CD", "ABCd"); | ||
assertToSqlNameEquals("AB_CD", "AbCD"); | ||
assertToSqlNameEquals("SOME_DETAILS_OBJECT", "SomeDetailsObject"); | ||
assertToSqlNameEquals("H_OL_A","hOlA"); | ||
assertToSqlNameEquals("A","a"); | ||
} | ||
|
||
/** | ||
* Helper method that asserts a CamelCaseString is converted to UPPER_CASE_UNDER_SCORE. | ||
* | ||
* @param expected a CamelCaseString | ||
* @param actual the expected UPPER_CASE_UNDER_SCORE string | ||
*/ | ||
private static void assertToSqlNameEquals(String expected, String actual) { | ||
assertEquals(expected, NamingHelper.toSQLNameDefault(actual)); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
library/src/test/java/com/orm/util/NumberComparatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.orm.util; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
public class NumberComparatorTest { | ||
private NumberComparator numberComparator = new NumberComparator(); | ||
|
||
@Test | ||
public void testNumberComparatorEquals() throws Exception { | ||
String a = "a"; | ||
String b = "a"; | ||
int compare = numberComparator.compare(a, b); | ||
assertEquals(0, compare); | ||
} | ||
|
||
@Test | ||
public void testNumberComparatorGreater() throws Exception { | ||
String a = "test"; | ||
String b = "foo"; | ||
int compare = numberComparator.compare(a, b); | ||
assertEquals(1, compare); | ||
} | ||
|
||
@Test | ||
public void testNumberComparatorLesser() throws Exception { | ||
String a = "foo"; | ||
String b = "test"; | ||
int compare = numberComparator.compare(a, b); | ||
assertEquals(-1, compare); | ||
} | ||
|
||
|
||
} |