daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.enseitankado;
  2.  
  3. import java.util.*;
  4. import org.junit.Test;
  5. import static org.junit.Assert.*;
  6. import org.junit.runners.JUnit4;
  7.  
  8. import org.junit.runner.RunWith;
  9. import org.junit.runners.Parameterized;
  10. import org.junit.runners.Parameterized.Parameters;
  11.  
  12.  
  13. @RunWith(Parameterized.class)
  14. public class SolutionTest {
  15.  
  16.     @Parameters
  17.     public static Collection<Object[]> data() {
  18.         return Arrays.asList( new Object[][] { {Arrays.asList("H", "O"),
  19.                 Arrays.asList( 2,   1 ),
  20.                 "H2O",
  21.                 "water"},
  22.  
  23.                 {Arrays.asList("Mg", "H", "O"),
  24.                         Arrays.asList(  1,   2,   2 ),
  25.                         "Mg(OH)2",
  26.                         "magnesium hydroxide"},
  27.  
  28.                 {Arrays.asList("K", "O", "N", "S"),
  29.                         Arrays.asList( 4,   14,  2,   4 ),
  30.                         "K4[ON(SO3)2]2",
  31.                         "Fremy's salt"},
  32.         });
  33.     }
  34.  
  35.     private Map<String,Integer> expected;
  36.     private String formula, name;
  37.  
  38.     public SolutionTest(List<String> atoms, List<Integer> nums, String formula, String name) {
  39.         Map<String,Integer> exp = new HashMap<String,Integer>();
  40.         for (int i = 0 ; i < atoms.size() ; i++) exp.put(atoms.get(i), nums.get(i));
  41.  
  42.         this.expected = exp;
  43.         this.formula = formula;
  44.         this.name = name;
  45.     }
  46.  
  47.     @Test
  48.     public void testMolecule() {
  49.         System.out.println(expected);
  50.         assertEquals(String.format("Should parse %s: %s", name, formula), expected, ParseMolecule.getAtoms(formula));
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top