Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2e0dea1
First commit
J-manLans Oct 2, 2025
3ac709e
deleted the dependabot file that kept issuing pr's
J-manLans Oct 9, 2025
cd8864a
[feature] Remove automatic PIT when executing *mvn test*
labe2301 Oct 10, 2025
ffcd39b
[feature] Add tests to AES
labe2301 Oct 16, 2025
25e9f88
[refactor] Rename AESTest
labe2301 Oct 18, 2025
43a6de0
[feature] Kill mutations in ColumnarTranspositionCipher
labe2301 Oct 18, 2025
faae7b2
[feature] Kill mutations and strengthen code for Caesar
labe2301 Oct 18, 2025
fa89220
[feature] Add tests to PlayfairCipher
labe2301 Oct 19, 2025
54ed855
Remove debug print statement from MyCaesarTest
labe2301 Oct 20, 2025
6ac3761
Restore PIT mutation coverage execution to pom.xml
labe2301 Oct 20, 2025
0a7b4c8
aded test for floor
hediinnT Oct 11, 2025
ba86402
aded test for closeParenthesisAnd
hediinnT Oct 11, 2025
ffad9a6
not run pitest when calling test
hediinnT Oct 11, 2025
9b9f86b
test for some random and divide by 0
hediinnT Oct 14, 2025
bcbc15d
done some romannumerals
hediinnT Oct 16, 2025
792f748
[feature] Create 100% line coverage, mutation coverage and test stren…
labe2301 Oct 18, 2025
38e811f
[feature] Increase line and mutation coverage for SimpsonIntegration
labe2301 Oct 18, 2025
6730e2e
added test for min,max.tolong
hediinnT Oct 19, 2025
09c91f3
tried to follow reviews
hediinnT Oct 21, 2025
e66760e
[bugfix] Fix minor bugs and misses and adds missing tests
labe2301 Oct 21, 2025
d4ed468
First commit on new tree branch
J-manLans Oct 18, 2025
44a7df4
Complete LCA test
J-manLans Oct 18, 2025
e911422
Added test to LSA for guarding against the parent and depth creation
J-manLans Oct 18, 2025
1f7d608
Started AVLSimpleTest
J-manLans Oct 18, 2025
5cf2b67
Rethought LCA
J-manLans Oct 19, 2025
a0d3586
Initial tests in AVLSimpleTest
J-manLans Oct 19, 2025
bd7bcee
Coverage tests done
J-manLans Oct 19, 2025
2124c7f
Test written for GenericTree
J-manLans Oct 19, 2025
80d99a9
Test push for GitHub Actions
J-manLans Oct 20, 2025
2296d5e
Generic tree done
J-manLans Oct 20, 2025
50d5ac6
Small changes regarding ConsoleInterceptor
J-manLans Oct 20, 2025
a7f100f
Restored the pom file for merge
J-manLans Oct 20, 2025
d2f53d1
Removed an effin TODO comment
J-manLans Oct 20, 2025
575f4ae
Added some empty/minimal tree tests
J-manLans Oct 21, 2025
0de92cc
Changed pitest phase in pom.xml
J-manLans Oct 22, 2025
1f91e34
fixed comment and added extra test for IEEE 754
hediinnT Oct 23, 2025
59cf6f4
from J-manLans, a good solution
hediinnT Oct 24, 2025
6fd9c0f
ran clang-format
hediinnT Oct 24, 2025
34fdc90
Corrected our additions
J-manLans Oct 27, 2025
a84d8d9
Corrected imports
J-manLans Oct 27, 2025
fad0916
Made style changes
J-manLans Oct 27, 2025
bdc9369
Made style changes
J-manLans Oct 27, 2025
3230715
Made style changes
J-manLans Oct 27, 2025
e2cbf27
Made style changes
J-manLans Oct 27, 2025
87f15fb
Made style changes
J-manLans Oct 27, 2025
c24cc40
Made style changes
J-manLans Oct 27, 2025
6774385
Made style changes
J-manLans Oct 27, 2025
eaf81c7
Made style changes
J-manLans Oct 27, 2025
f61786b
Made style changes
J-manLans Oct 27, 2025
96b539d
Made style changes
J-manLans Oct 27, 2025
177f115
Made style changes
J-manLans Oct 28, 2025
79771a3
Added test documentation
J-manLans Oct 28, 2025
1f9d15a
Added pom dev profile
J-manLans Oct 29, 2025
fd3e28d
refactor: Merge files testing the same packages
labe2301 Oct 29, 2025
a888944
refactor: Fix imports to satisfy PMD
labe2301 Oct 29, 2025
a16e8ed
Added pom dev profile
J-manLans Oct 31, 2025
c047bee
Merge branch 'master' into test-contributions-master
J-manLans Oct 31, 2025
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
18 changes: 0 additions & 18 deletions .github/dependabot.yml

This file was deleted.

73 changes: 73 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
<artifactId>commons-collections4</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.9.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -155,4 +161,71 @@
</plugin>
</plugins>
</build>

<profiles>
<profile> <!-- Use with `mvn clean test -Pdev` to generate PIT coverage reports for your tests -->
<id>dev</id>

<properties> <!-- Modify this section to change target(s) -->
<modulename>datastructures</modulename>
<packagename>trees</packagename>
<classname>AVLSimple</classname>
</properties>

<build>
<plugins>
<plugin> <!-- Surefire -->
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>com/thealgorithms/${modulename}/${packagename}/${classname}Test.java</include>
</includes>
</configuration>
</plugin>

<plugin> <!-- PIT Mutation Testing Plugin -->
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.21.0</version>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<configuration>
<!-- Classes to mutate -->
<targetClasses>com.thealgorithms.${modulename}.${packagename}.${classname}*</targetClasses>
<!-- Test classes to run -->
<targetTests>com.thealgorithms.${modulename}.${packagename}.${classname}Test</targetTests>
<mutators> <!-- Mutation operators to use -->
<mutator>DEFAULTS</mutator>
</mutators>
<threads>2</threads> <!-- Number of threads -->
<outputFormats>
<param>HTML</param>
<param>XML</param>
</outputFormats>
<timeoutConstant>4000</timeoutConstant> <!-- Timeout in milliseconds -->
<jvmArgs> <!-- RAM in MB per thread -->
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
<!-- Skip failing tests so whole suite will run - good for development-->
<skipFailingTests>true</skipFailingTests>
</configuration>
<executions>
<execution>
<id>run-pitest</id>
<phase>test</phase> <!-- bind to test-phase -->
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class AVLSimple {

private class Node {
private static class Node {

int data;
int height;
Expand Down Expand Up @@ -82,6 +82,11 @@ private Node insert(Node node, int item) {
}

public void display() {
if (root == null) {
System.out.println("Tree is empty");
return;
}

this.display(this.root);
System.out.println(this.root.height);
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/thealgorithms/datastructures/trees/LCA.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ public final class LCA {
private LCA() {
}

private static final Scanner SCANNER = new Scanner(System.in);

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// The adjacency list representation of a tree:
ArrayList<ArrayList<Integer>> adj = new ArrayList<>();

// v is the number of vertices and e is the number of edges
int v = SCANNER.nextInt();
int v = scanner.nextInt();
int e = v - 1;

for (int i = 0; i < v; i++) {
adj.add(new ArrayList<Integer>());
adj.add(new ArrayList<>());
}

// Storing the given tree as an adjacency list
int to;
int from;
for (int i = 0; i < e; i++) {
to = SCANNER.nextInt();
from = SCANNER.nextInt();
to = scanner.nextInt();
from = scanner.nextInt();

adj.get(to).add(from);
adj.get(from).add(to);
Expand All @@ -42,8 +42,8 @@ public static void main(String[] args) {
dfs(adj, 0, -1, parent, depth);

// Inputting the two vertices whose LCA is to be calculated
int v1 = SCANNER.nextInt();
int v2 = SCANNER.nextInt();
int v1 = scanner.nextInt();
int v2 = scanner.nextInt();

// Outputting the LCA
System.out.println(getLCA(v1, v2, depth, parent));
Expand Down
167 changes: 167 additions & 0 deletions src/test/java/com/thealgorithms/ciphers/AESTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package com.thealgorithms.ciphers;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import java.math.BigInteger;
import org.junit.jupiter.api.Test;

public class AESTest {
@Test
void testScheduleCore() {
BigInteger input = new BigInteger("1a2b3c4d", 16);
int rconCounter = 1;

BigInteger expected = new BigInteger("f0ebe3a2", 16);

BigInteger result = AES.scheduleCore(input, rconCounter);
assertEquals(expected, result, "Should return " + expected);
}

@Test
void testKeyExpansion() {
BigInteger initialKey = new BigInteger("000102030405060708090a0b0c0d0e0f", 16);

BigInteger[] roundKeys = AES.keyExpansion(initialKey);

assertEquals(initialKey, roundKeys[0], "First round key should match initial key");

for (int i = 1; i < roundKeys.length; i++) {
assertNotEquals(BigInteger.ZERO, roundKeys[i], "Round key " + i + " should not be zero");
}
}

@Test
void testSplitBlockIntoCells() {
StringBuilder binary = new StringBuilder();

for (int i = 1; i <= 16; i++) {
String byteStr = String.format("%8s", Integer.toBinaryString(i)).replace(" ", "0");
binary.append(byteStr);
}

BigInteger block = new BigInteger(binary.toString(), 2);

int[] expected = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};

int[] result = AES.splitBlockIntoCells(block);

assertArrayEquals(expected, result);
}

@Test
void testMergeCellsIntoBlocks() {
int[] cells = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};

StringBuilder expectedBinary = new StringBuilder();

for (int cell : cells) {
expectedBinary.append(String.format("%8s", Integer.toBinaryString(cell)).replace(" ", "0"));
}

BigInteger expected = new BigInteger(expectedBinary.toString(), 2);

BigInteger result = AES.mergeCellsIntoBlock(cells);

assertEquals(expected, result, "Merged block from cells should match expected BigInteger");
}

@Test
void testAddRoundKey() {
BigInteger ciphertext = new BigInteger("a1b2c3d5e5f60718", 16);
BigInteger key = new BigInteger("0f0e0d0c0b0a0909", 16);

BigInteger expected = new BigInteger("12591166093633785361");

BigInteger result = AES.addRoundKey(ciphertext, key);

assertEquals(expected, result, "Should return XOR of ciphertext and key");
}

@Test
void testSubBytes() {
BigInteger input = new BigInteger("000102030405060708090a0b0c0d0e0f", 16);

BigInteger expected = new BigInteger("132239839819997069106320266673331350390");

BigInteger result = AES.subBytes(input);

assertEquals(expected, result, "Should match correct S-Box substituted block");
}

@Test
void testSubBytesDec() {
BigInteger originalBlock = new BigInteger("3243f6a8885a308d313198a2e0370734", 16);

BigInteger afterSubBytes = AES.subBytes(originalBlock);
BigInteger afterInverse = AES.subBytesDec(afterSubBytes);

assertEquals(originalBlock, afterInverse, "subBytesDec should reverse subBytes");
}

@Test
void testShiftRows() {
BigInteger input = new BigInteger("00010203101112132021222330313233", 16);

BigInteger expected = new BigInteger("00112233102132032031021330011223", 16);

BigInteger result = AES.shiftRows(input);

assertEquals(expected, result, "Should shift rows correctly");
}

@Test
void testShiftRowsDec() {
BigInteger originalBlock = new BigInteger("00010203101112132021222330313233", 16);

BigInteger shifted = AES.shiftRows(originalBlock);
BigInteger unshifted = AES.shiftRowsDec(shifted);

assertEquals(originalBlock, unshifted, "shiftRowsDec should reverse shiftRows");
}

@Test
void testMixColumns() {
BigInteger input = new BigInteger("d4bf5d30e0b452aeb84111f11e2798e5", 16);

BigInteger expected = new BigInteger("046681e5e0cb199a48f8d37a2806264c", 16);

BigInteger result = AES.mixColumns(input);

assertEquals(expected, result, "MixColumns output did not match expected value");
}

@Test
void testMixColumnsDec() {
BigInteger input = new BigInteger("000102030405060708090a0b0c0d0e0f", 16);

BigInteger mixed = AES.mixColumns(input);
BigInteger unmixed = AES.mixColumnsDec(mixed);

assertEquals(input, unmixed, "mixColumnsDec should reverse mixColumns");
}

@Test
void testEncrypt() {
BigInteger plainText = new BigInteger("00112233445566778899aabbccddeeff", 16);
BigInteger key = new BigInteger("000102030405060708090a0b0c0d0e0f", 16);

BigInteger expectedCipherText = new BigInteger("69c4e0d86a7b0430d8cdb78070b4c55a", 16);

BigInteger actualCipherText = AES.encrypt(plainText, key);

assertEquals(expectedCipherText, actualCipherText, "Encrypt output should match known ciphertext");
}

@Test
void testDecrypt() {
BigInteger plaintext = new BigInteger("00112233445566778899aabbccddeeff", 16);
BigInteger key = new BigInteger("000102030405060708090a0b0c0d0e0f", 16);

BigInteger ciphertext = AES.encrypt(plaintext, key);
BigInteger decrypted = AES.decrypt(ciphertext, key);

assertEquals(plaintext, decrypted, "Decrypt should reverse Encrypt");
}
}
Loading