Browse Source

add some testing

master^2
parent
commit
1d9cfe6e36
8 changed files with 202 additions and 6 deletions
  1. +2
    -2
      .classpath
  2. +7
    -0
      pom.xml
  3. +0
    -1
      some_new_file.txt
  4. +1
    -1
      src/main/java/com/gmail/develop/jcant/JDate.java
  5. +190
    -0
      src/test/java/com/gmail/develop/jcant/JDateTest.java
  6. BIN
      target/classes/com/gmail/develop/jcant/JDate.class
  7. +1
    -1
      target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  8. +1
    -1
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

+ 2
- 2
.classpath View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -18,9 +18,9 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>


+ 7
- 0
pom.xml View File

@ -19,6 +19,13 @@
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>


+ 0
- 1
some_new_file.txt View File

@ -1 +0,0 @@
asdf asdf asdf adsf adsf adsf afds adsf

+ 1
- 1
src/main/java/com/gmail/develop/jcant/JDate.java View File

@ -121,7 +121,7 @@ public class JDate {
our.set(Calendar.HOUR_OF_DAY, setter.get(Calendar.HOUR_OF_DAY));
our.set(Calendar.MINUTE, setter.get(Calendar.MINUTE));
our.set(Calendar.SECOND, 0);
our.set(Calendar.SECOND, setter.get(Calendar.SECOND));
return our.getTime();
}


+ 190
- 0
src/test/java/com/gmail/develop/jcant/JDateTest.java View File

@ -0,0 +1,190 @@
package com.gmail.develop.jcant;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Date;
import org.junit.jupiter.api.Test;
public class JDateTest {
@Test
public void testSetDefaultDateFormat() {
JDate.setDefaultDateFormat("DD/MM/YYYY");
assertEquals(JDate.getDefaultDateFormat(), "DD/MM/YYYY");
JDate.setDefaultDateFormat("dd-MM-yyyy");
}
@Test
public void testGetDefaultDateFormat() {
JDate.setDefaultDateFormat("DD/MM/YYYY");
assertEquals(JDate.getDefaultDateFormat(), "DD/MM/YYYY");
JDate.setDefaultDateFormat("dd-MM-yyyy");
}
@Test
public void testSetDefaultTimeFormat() {
JDate.setDefaultTimeFormat("HH-MM-SS");
assertEquals(JDate.getDefaultTimeFormat(), "HH-MM-SS");
JDate.setDefaultTimeFormat("HH:mm:ss");
}
@Test
public void testGetDefaultTimeFormat() {
JDate.setDefaultTimeFormat("HH-MM-SS");
assertEquals(JDate.getDefaultTimeFormat(), "HH-MM-SS");
JDate.setDefaultTimeFormat("HH:mm:ss");
}
@Test
public void testCreateDate() {
//test creation '01-January-2021':
assertEquals(JDate.createDate(01, 00, 2021).getTime(), 1609452000000l); //01-01-2021 00:00:00
}
@Test
public void testGetDateString() {
assertEquals(JDate.getDate("05-05-2021").getTime(), 1620162000000l); //05-05-2021 00:00:00
}
@Test
public void testGetDateStringString() {
assertEquals(JDate.getDate("05-05-2021", "08:30:30").getTime(), 1620192630000l); //05-05-2021 08:30:30
}
@Test
public void testGetDateDate() {
Date date = new Date(1620192630000l); //05-05-2021 08:30:30
assertEquals(JDate.getDate(date), "05-05-2021");
}
@Test
public void testSetDateDateString() {
Date date = new Date(1620192630000l); //05-05-2021 08:30:30
assertEquals(JDate.setDate(date, "10-10-2022").getTime(), 1665379830000l); //10-10-2022 08:30:30
}
@Test
public void testSetDateDateIntIntInt() {
//test creation '10-October-2022':
Date date = new Date(1620192630000l); //05-05-2021 08:30:30
assertEquals(JDate.setDate(date, 10, 9, 2022).getTime(), 1665379830000l); //10-10-2022 08:30:30
}
@Test
public void testGetTime() {
Date date = new Date(1620192630000l); //05-05-2021 08:30:30
assertEquals(JDate.getTime(date), "08:30:30");
}
@Test
public void testSetTimeDateString() {
Date date = new Date(1665379830000l); //10-10-2022 08:30:30
assertEquals(JDate.setTime(date, "12:48:11").getTime(), 1665395291000l); //10-10-2022 12:48:11
}
@Test
public void testSetTimeDateIntIntInt() {
Date date = new Date(1665379830000l); //10-10-2022 08:30:30
assertEquals(JDate.setTime(date, 12, 48, 11).getTime(), 1665395291000l); //10-10-2022 12:48:11
}
@Test
public void testNullTime() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.nullTime(date).getTime(), 1665349200000l); //10-10-2022 00:00:00
}
@Test
public void testGetHours() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.getHours(date), 12);
}
@Test
public void testGetMinutes() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.getMinutes(date), 48);
}
@Test
public void testGetSeconds() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.getSeconds(date), 11);
}
@Test
public void testIncHours() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.incHours(date, 3).getTime(), 1665406091000l); //10-10-2022 15:48:11
}
@Test
public void testIncMinutes() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.incMinutes(date, -10).getTime(), 1665394691000l); //10-10-2022 12:38:11
}
@Test
public void testIncSeconds() {
Date date = new Date(1665395291000l); //10-10-2022 12:48:11
assertEquals(JDate.incSeconds(date, 20).getTime(), 1665395311000l); //10-10-2022 12:48:31
}
@Test
public void testGetDifferenceDays() {
Date date1 = new Date(1665395291000l); //10-10-2022 12:48:11
Date date2 = new Date(1662185523000l); //03-09-2022 09:12:03
Date date3 = new Date(1662200115000l); //03-09-2022 13:15:15
assertTrue((JDate.getDifferenceDays(date1, date2) == -37) && (JDate.getDifferenceDays(date3, date1) == 36));
}
@Test
public void testGetDifferenceYears() {
fail("Not yet implemented");
}
@Test
public void testGetWeekDay() {
fail("Not yet implemented");
}
@Test
public void testGetDay() {
fail("Not yet implemented");
}
@Test
public void testGetMonth() {
fail("Not yet implemented");
}
@Test
public void testGetCorrectMonth() {
fail("Not yet implemented");
}
@Test
public void testGetYear() {
fail("Not yet implemented");
}
@Test
public void testIncDay() {
fail("Not yet implemented");
}
@Test
public void testIncMonth() {
fail("Not yet implemented");
}
@Test
public void testIncYear() {
fail("Not yet implemented");
}
}

BIN
target/classes/com/gmail/develop/jcant/JDate.class View File


+ 1
- 1
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst View File

@ -1 +1 @@
com/gmail/develop/jcant/JDate.class
com\gmail\develop\jcant\JDate.class

+ 1
- 1
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst View File

@ -1 +1 @@
/home/jcadm/LuckyProject/Helpers/JDate/src/main/java/com/gmail/develop/jcant/JDate.java
D:\JC\Develop\Java\JDate\src\main\java\com\gmail\develop\jcant\JDate.java

Loading…
Cancel
Save