From 11a3bade54c092b4551d534a269a7f488813c6df Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 16 Dec 2017 16:20:21 -0800 Subject: [PATCH] Add unit test for PluginOptions --- .../github/shadowsocks/ExampleUnitTest.java | 17 --------- .../shadowsocks/plugin/ExampleUnitTest.java | 17 --------- .../shadowsocks/plugin/PluginOptionsTest.kt | 38 +++++++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) delete mode 100644 core/src/test/java/com/github/shadowsocks/ExampleUnitTest.java delete mode 100644 plugin/src/test/java/com/github/shadowsocks/plugin/ExampleUnitTest.java create mode 100644 plugin/src/test/java/com/github/shadowsocks/plugin/PluginOptionsTest.kt diff --git a/core/src/test/java/com/github/shadowsocks/ExampleUnitTest.java b/core/src/test/java/com/github/shadowsocks/ExampleUnitTest.java deleted file mode 100644 index 997edea9..00000000 --- a/core/src/test/java/com/github/shadowsocks/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.shadowsocks; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/plugin/src/test/java/com/github/shadowsocks/plugin/ExampleUnitTest.java b/plugin/src/test/java/com/github/shadowsocks/plugin/ExampleUnitTest.java deleted file mode 100644 index 7b4ec7d4..00000000 --- a/plugin/src/test/java/com/github/shadowsocks/plugin/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.shadowsocks.plugin; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/plugin/src/test/java/com/github/shadowsocks/plugin/PluginOptionsTest.kt b/plugin/src/test/java/com/github/shadowsocks/plugin/PluginOptionsTest.kt new file mode 100644 index 00000000..9829f2de --- /dev/null +++ b/plugin/src/test/java/com/github/shadowsocks/plugin/PluginOptionsTest.kt @@ -0,0 +1,38 @@ +/******************************************************************************* + * * + * Copyright (C) 2017 by Max Lv * + * Copyright (C) 2017 by Mygod Studio * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +package com.github.shadowsocks.plugin + +import org.junit.Assert +import org.junit.Test + +class PluginOptionsTest { + @Test + fun equal() { + val o1 = PluginOptions("obfs-local;obfs=http;obfs-host=localhost") + val o2 = PluginOptions("obfs-local", "obfs-host=localhost;obfs=http") + Assert.assertEquals(o1.hashCode(), o2.hashCode()) + Assert.assertEquals(true, o1 == o2) + val o3 = PluginOptions(o1.toString(false)) + Assert.assertEquals(true, o2 == o3) + val o4 = PluginOptions(o2.id, o2.toString()) + Assert.assertEquals(true, o3 == o4) + } +}