GitHub PullRequestReviewCommentEvent at 2014-04-03 21:14:56
Repository: watchdog
Actor: nightraven
Payload: {"comment":{"url":"https://api.github.com/repos/TestRoots/watchdog/pulls/comments/11273092","id":11273092,"diff_hunk":"@@ -0,0 +1,104 @@\n+package nl.tudelft.watchdog.interval;\n+\n+import java.io.File;\n+import java.nio.file.Paths;\n+import java.util.ArrayList;\n+import java.util.Date;\n+import java.util.List;\n+import java.util.Random;\n+\n+import nl.tudelft.watchdog.logic.interval.LevelDBPersister;\n+import nl.tudelft.watchdog.logic.interval.active.IntervalBase;\n+import nl.tudelft.watchdog.logic.interval.active.SessionInterval;\n+\n+import org.junit.After;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+public class LevelDBPersisterTest {\n+\n+\tpublic static final String path = \"test.leveldb\";\n+\n+\t@Before\n+\tpublic void before() {\n+\t\tcleanup();\n+\t}\n+\n+\t@After\n+\tpublic void after() {\n+\t\tcleanup();\n+\t}\n+\n+\t@Test\n+\tpublic void testWriteToDB() {\n+\t\tLevelDBPersister persister = new LevelDBPersister(path);\n+\t\tList<IntervalBase> intervals = genIntervalList(10);\n+\t\tpersister.saveIntervals(intervals);\n+\n+\t\tList<IntervalBase> loaded = persister.readIntevals(0, Long.MAX_VALUE);\n+\t\tfor (int i = 0; i < 10; i++) {\n+\t\t\tassert (loaded.get(i).equals(intervals.get(i)));\n+\t\t}\n+\t}\n+\n+\t@Test\n+\tpublic void readFromDB() {\n+\t\tLevelDBPersister persister = new LevelDBPersister(path);\n+\t\tpersister.readIntevals(0, Long.MAX_VALUE);\n+\t}\n+\n+\t@Test\n+\tpublic void testlongToByteArray() {\n+\t\tbyte[] bytes = LevelDBPersister.longToByteArray(4);\n+\n+\t\tassert (bytes.length == 8);\n+\t\tassert (bytes[7] == 4);\n+\n+\t\tbytes = LevelDBPersister.longToByteArray(16);\n+\n+\t\tassert (bytes.length == 8);\n+\t\tassert (bytes[7] == 0xf);\n+\n+\t\tbytes = LevelDBPersister.longToByteArray(257);\n+\n+\t\tassert (bytes.length == 8);\n+\t\tassert (bytes[7] == 0xff);\n+\t\tassert (bytes[6] == 0x1);\n+\t}\n+\n+\t@Test\n+\tpublic void testByteArraytoLong() {\n+\t\tbyte[] bytes = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x12 };\n+\t\tassert (LevelDBPersister.byteArraytoLong(bytes) == 268);\n+\t}\n+\n+\tprivate List<IntervalBase> genIntervalList(int n) {\n+\n+\t\tList<IntervalBase> intervals = new ArrayList<IntervalBase>();\n+\t\tfor (int i = 0; i < n; i++) {\n+\t\t\tintervals.add(rndInterval());\n+\t\t}\n+\t\treturn intervals;\n+\t}\n+\n+\tprivate IntervalBase rndInterval() {","path":"WatchDogUnitTests/src/nl/tudelft/watchdog/interval/LevelDBPersisterTest.java","position":84,"original_position":84,"commit_id":"528ab7a60d3097ea0172db38fa54c214a9a19e82","original_commit_id":"528ab7a60d3097ea0172db38fa54c214a9a19e82","user":{"login":"nightraven","id":334256,"avatar_url":"https://avatars.githubusercontent.com/u/334256?","gravatar_id":"25b50477a407c8cebb3bad8454d4115a","url":"https://api.github.com/users/nightraven","html_url":"https://github.com/nightraven","followers_url":"https://api.github.com/users/nightraven/followers","following_url":"https://api.github.com/users/nightraven/following{/other_user}","gists_url":"https://api.github.com/users/nightraven/gists{/gist_id}","starred_url":"https://api.github.com/users/nightraven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightraven/subscriptions","organizations_url":"https://api.github.com/users/nightraven/orgs","repos_url":"https://api.github.com/users/nightraven/repos","events_url":"https://api.github.com/users/nightraven/events{/privacy}","received_events_url":"https://api.github.com/users/nightraven/received_events","type":"User","site_admin":false},"body":"You adapt the name as is appropriate then? ;-)","created_at":"2014-04-03T21:14:56Z","updated_at":"2014-04-03T21:14:56Z","html_url":"https://github.com/TestRoots/watchdog/pull/31#discussion_r11273092","pull_request_url":"https://api.github.com/repos/TestRoots/watchdog/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/TestRoots/watchdog/pulls/comments/11273092"},"html":{"href":"https://github.com/TestRoots/watchdog/pull/31#discussion_r11273092"},"pull_request":{"href":"https://api.github.com/repos/TestRoots/watchdog/pulls/31"}}}}