mirror of
https://github.com/monero-project/research-lab.git
synced 2024-12-22 03:29:32 +00:00
Merge pull request #28 from h908714124/add-maven-pom
add a maven pom, and a basic unit test, to StringCT-java
This commit is contained in:
commit
ce82e4a0c1
6 changed files with 124 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# c
|
||||
*.o
|
||||
|
||||
# Maven
|
||||
target
|
||||
|
||||
# Intellij IDEA
|
||||
.idea
|
||||
*.iml
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
85
source-code/StringCT-java/pom.xml
Normal file
85
source-code/StringCT-java/pom.xml
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>research-lab</groupId>
|
||||
<artifactId>StringCT</artifactId>
|
||||
<version>0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<!-- Dependency versions -->
|
||||
<junit.version>4.12</junit.version>
|
||||
<bcprov-jdk15on.version>1.59</bcprov-jdk15on.version>
|
||||
<commons-pool2.version>2.4.2</commons-pool2.version>
|
||||
<commons-codec.version>1.10</commons-codec.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-debug-jdk15on</artifactId>
|
||||
<version>${bcprov-jdk15on.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>${commons-pool2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
==========
|
||||
Test scope
|
||||
==========
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<forkCount>1</forkCount>
|
||||
<reuseForks>false</reuseForks>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<version>3.0.1</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,29 @@
|
|||
package org.nem.core.utils;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ArrayUtilsTest {
|
||||
|
||||
@Test
|
||||
public void duplicate() {
|
||||
|
||||
// Arrange
|
||||
byte[] bytes = "test".getBytes(StandardCharsets.UTF_8);
|
||||
int bytesHash = Arrays.hashCode(bytes);
|
||||
|
||||
// Act
|
||||
byte[] duplicate = ArrayUtils.duplicate(bytes);
|
||||
|
||||
// Assert: original array is unchanged
|
||||
assertEquals(bytesHash, Arrays.hashCode(bytes));
|
||||
|
||||
// Assert: check duplicate
|
||||
assertArrayEquals(bytes, duplicate);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue