Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Test#37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tonyzzz1997 wants to merge2 commits intorampatra:master
base:master
Choose a base branch
Loading
fromtonyzzz1997:test
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletionsRecursiveDigitSumTest.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
package recursion;

import static org.junit.jupiter.api.Assertions.assertThrows;

import javax.annotation.processing.Generated;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

@Generated(value = "org.junit-tools-1.1.0")
public class RecursiveDigitSumTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
System.out.println("BeforeClass");
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
System.out.println("AfterClass");
}

@Test
public void testSuperDigitWithNull() throws Exception {
// TC1
int k = 0;
String n = null;
String expected = "by input exception [" + n + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

@Test
public void testSuperDigitWithEmpty() throws Exception {
// TC2
int k = 1;
String n = "";
int expected = 0;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitWithNegative1() throws Exception {
// TC3
int k = -1;
String n = "1";
String expected = "by input exception [" + k + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

@Test
public void testSuperDigit1() throws Exception {
// TC4
int k = 0;
String n = "1";
int expected = 1;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitMax1() throws Exception {
// TC5
int k = 999999999;
String n = "1";
int expected = 9;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigit3() throws Exception {
// TC6
int k = 0;
String n = "12";
int expected = 3;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigit4() throws Exception {
// TC7
int k = 1;
String n = "12";
int expected = 3;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitMax2() throws Exception {
// TC8
int k = 1;
String n = "999999999";
int expected = 9;
int result = RecursiveDigitSum.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitWithNegative2() throws Exception {
// TC9
int k = 1;
String n = "-a";
String expected = "by input exception [" + n + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

}
127 changes: 127 additions & 0 deletionsRecursiveDigitSumTest2.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
package recursion;

import static org.junit.jupiter.api.Assertions.assertThrows;

import javax.annotation.processing.Generated;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

@Generated(value = "org.junit-tools-1.1.0")
public class RecursiveDigitSumTest2 {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
System.out.println("BeforeClass");
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
System.out.println("AfterClass");
}

@Test
public void testSuperDigitWithNull() throws Exception {
// TC1
int k = 0;
String n = null;
String expected = "by input exception [" + n + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum2.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

@Test
public void testSuperDigitWithEmpty() throws Exception {
// TC2
int k = 1;
String n = "";
int expected = 0;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitWithNegative1() throws Exception {
// TC3
int k = -1;
String n = "1";
String expected = "by input exception [" + k + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum2.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

@Test
public void testSuperDigit1() throws Exception {
// TC4
int k = 0;
String n = "1";
int expected = 1;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitMax1() throws Exception {
// TC5
int k = 999999999;
String n = "1";
int expected = 9;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigit3() throws Exception {
// TC6
int k = 0;
String n = "12";
int expected = 3;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigit4() throws Exception {
// TC7
int k = 1;
String n = "12";
int expected = 3;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitMax2() throws Exception {
// TC8
int k = 1;
String n = "999999999";
int expected = 9;
int result = RecursiveDigitSum2.superDigit(n, k);

Assert.assertEquals(expected, result);
}

@Test
public void testSuperDigitWithNegative2() throws Exception {
// TC9
int k = 1;
String n = "-a";
String expected = "by input exception [" + n + "]";
Exception result = assertThrows(Exception.class,
() -> RecursiveDigitSum2.superDigit(n, k));

Assert.assertEquals(expected, result.getMessage());
}

}

[8]ページ先頭

©2009-2025 Movatter.jp