Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
plugins/net.bioclipse.core.tests/src/net/bioclipse/core/domain/SparseDatasetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Copyright (c) 2012 Jonathan Alvarsson | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Jonathan Alvarsson - Initial implementation | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
package net.bioclipse.core.domain; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.awt.Point; | ||
import java.util.Arrays; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
public class SparseDatasetTest { | ||
|
||
@Test | ||
public void testToSparseString() { | ||
|
||
List<String> colHeaders = Arrays.asList( "c1", "c2", "c3", "c4" ); | ||
List<String> rowHeaders = Arrays.asList( "r1", "r2", "r3", "r4" ); | ||
LinkedHashMap<Point, Integer> values | ||
= new LinkedHashMap<Point, Integer>() {{ | ||
put( new Point( 1, 1 ), 1 ); | ||
put( new Point( 1, 2 ), 12); | ||
put( new Point( 2, 2 ), 2); | ||
put( new Point( 3, 2 ), 32); | ||
put( new Point( 3, 3 ), 3); | ||
}}; | ||
SparseDataset dataset = new SparseDataset( colHeaders, | ||
rowHeaders, | ||
values ); | ||
assertEquals( "1:1,2:12\n2:2\n2:32,3:3\n", | ||
dataset.toSparseString(",") ); | ||
} | ||
} |