Seth 6 år sedan
förälder
incheckning
1546ea5fb7
3 ändrade filer med 118 tillägg och 56 borttagningar
  1. 50
    44
      .idea/workspace.xml
  2. 11
    0
      arraz/src/main/java/Arraz.java
  3. 57
    12
      arraz/src/test/java/ArrazTest.java

+ 50
- 44
.idea/workspace.xml Visa fil

@@ -2,7 +2,6 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="3455511b-a100-4bbd-b07c-68f009bc8dbc" name="Default" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6 5
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
7 6
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
8 7
     </list>
@@ -23,7 +22,7 @@
23 22
       </usages-collector>
24 23
       <usages-collector id="statistics.file.types.edit">
25 24
         <counts>
26
-          <entry key="JAVA" value="7562" />
25
+          <entry key="JAVA" value="8890" />
27 26
           <entry key="XML" value="3" />
28 27
         </counts>
29 28
       </usages-collector>
@@ -41,8 +40,8 @@
41 40
       <file pinned="false" current-in-tab="true">
42 41
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
43 42
           <provider selected="true" editor-type-id="text-editor">
44
-            <state relative-caret-position="167">
45
-              <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
43
+            <state relative-caret-position="372">
44
+              <caret line="294" column="44" selection-start-line="294" selection-start-column="44" selection-end-line="294" selection-end-column="44" />
46 45
               <folding>
47 46
                 <element signature="imports" expanded="true" />
48 47
                 <element signature="e#4388#4389#0" expanded="true" />
@@ -55,17 +54,16 @@
55 54
       <file pinned="false" current-in-tab="false">
56 55
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
57 56
           <provider selected="true" editor-type-id="text-editor">
58
-            <state relative-caret-position="313">
59
-              <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
60
-            </state>
61
-          </provider>
62
-        </entry>
63
-      </file>
64
-      <file pinned="false" current-in-tab="false">
65
-        <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/src.zip!/java/util/Set.java">
66
-          <provider selected="true" editor-type-id="text-editor">
67
-            <state relative-caret-position="386">
68
-              <caret line="189" column="17" selection-start-line="189" selection-start-column="17" selection-end-line="189" selection-end-column="17" />
57
+            <state relative-caret-position="388">
58
+              <caret line="140" lean-forward="true" selection-start-line="140" selection-end-line="140" />
59
+              <folding>
60
+                <element signature="e#3351#3352#0" expanded="true" />
61
+                <element signature="e#3376#3377#0" expanded="true" />
62
+                <element signature="e#3440#3441#0" expanded="true" />
63
+                <element signature="e#3482#3483#0" expanded="true" />
64
+                <element signature="e#3556#3557#0" expanded="true" />
65
+                <element signature="e#3603#3604#0" expanded="true" />
66
+              </folding>
69 67
             </state>
70 68
           </provider>
71 69
         </entry>
@@ -215,7 +213,7 @@
215 213
     <property name="GO_FMT" value="false" />
216 214
     <property name="WebServerToolWindowFactoryState" value="false" />
217 215
     <property name="aspect.path.notification.shown" value="true" />
218
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544188738035" />
216
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544190595334" />
219 217
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
220 218
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
221 219
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
@@ -245,7 +243,7 @@
245 243
       </list>
246 244
     </option>
247 245
   </component>
248
-  <component name="RunManager" selected="JUnit.ArrazTest.testRemoveDupesFromArray2">
246
+  <component name="RunManager" selected="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2">
249 247
     <configuration default="true" type="Applet" factoryName="Applet">
250 248
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
251 249
       <method v="2">
@@ -258,33 +256,33 @@
258 256
         <option name="Make" enabled="true" />
259 257
       </method>
260 258
     </configuration>
261
-    <configuration name="ArrazTest.testCopyArrayByIterator2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
259
+    <configuration name="ArrazTest.testMakeMeAnArrayFromArrayList1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
262 260
       <module name="arraz" />
263 261
       <option name="PACKAGE_NAME" value="" />
264 262
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
265
-      <option name="METHOD_NAME" value="testCopyArrayByIterator2" />
263
+      <option name="METHOD_NAME" value="testMakeMeAnArrayFromArrayList1" />
266 264
       <option name="TEST_OBJECT" value="method" />
267 265
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
268 266
       <method v="2">
269 267
         <option name="Make" enabled="true" />
270 268
       </method>
271 269
     </configuration>
272
-    <configuration name="ArrazTest.testFindMaxMinOfArray1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
270
+    <configuration name="ArrazTest.testMakeMeAnArrayListFromArray1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
273 271
       <module name="arraz" />
274 272
       <option name="PACKAGE_NAME" value="" />
275 273
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
276
-      <option name="METHOD_NAME" value="testFindMaxMinOfArray1" />
274
+      <option name="METHOD_NAME" value="testMakeMeAnArrayListFromArray1" />
277 275
       <option name="TEST_OBJECT" value="method" />
278 276
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
279 277
       <method v="2">
280 278
         <option name="Make" enabled="true" />
281 279
       </method>
282 280
     </configuration>
283
-    <configuration name="ArrazTest.testFindMaxMinOfArray2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
281
+    <configuration name="ArrazTest.testMakeMeAnArrayListFromArray2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
284 282
       <module name="arraz" />
285 283
       <option name="PACKAGE_NAME" value="" />
286 284
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
287
-      <option name="METHOD_NAME" value="testFindMaxMinOfArray2" />
285
+      <option name="METHOD_NAME" value="testMakeMeAnArrayListFromArray2" />
288 286
       <option name="TEST_OBJECT" value="method" />
289 287
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
290 288
       <method v="2">
@@ -337,19 +335,19 @@
337 335
       </method>
338 336
     </configuration>
339 337
     <list>
340
-      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
341
-      <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray1" />
342
-      <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray2" />
343 338
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
344 339
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
340
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray1" />
341
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2" />
342
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayFromArrayList1" />
345 343
     </list>
346 344
     <recent_temporary>
347 345
       <list>
346
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2" />
347
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayFromArrayList1" />
348
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray1" />
348 349
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
349 350
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
350
-        <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray2" />
351
-        <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray1" />
352
-        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
353 351
       </list>
354 352
     </recent_temporary>
355 353
   </component>
@@ -366,7 +364,7 @@
366 364
       <workItem from="1543955862749" duration="2347000" />
367 365
       <workItem from="1543958998826" duration="113000" />
368 366
       <workItem from="1544020724645" duration="762000" />
369
-      <workItem from="1544046933389" duration="22466000" />
367
+      <workItem from="1544046933389" duration="24417000" />
370 368
     </task>
371 369
     <task id="LOCAL-00001" summary="readme and docs">
372 370
       <created>1544021313039</created>
@@ -379,15 +377,6 @@
379 377
     <servers />
380 378
   </component>
381 379
   <component name="TestHistory">
382
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 05s.xml">
383
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
384
-    </history-entry>
385
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 50s.xml">
386
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
387
-    </history-entry>
388
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 59s.xml">
389
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
390
-    </history-entry>
391 380
     <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 34m 13s.xml">
392 381
       <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
393 382
     </history-entry>
@@ -409,9 +398,18 @@
409 398
     <history-entry file="ArrazTest_testRemoveDupesFromArray1 - 2018.12.07 at 08h 15m 32s.xml">
410 399
       <configuration name="ArrazTest.testRemoveDupesFromArray1" configurationId="JUnit" />
411 400
     </history-entry>
401
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.07 at 08h 18m 59s.xml">
402
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
403
+    </history-entry>
404
+    <history-entry file="ArrazTest_testMakeMeAnArrayListFromArray1 - 2018.12.07 at 08h 40m 21s.xml">
405
+      <configuration name="ArrazTest.testMakeMeAnArrayListFromArray1" configurationId="JUnit" />
406
+    </history-entry>
407
+    <history-entry file="ArrazTest_testMakeMeAnArrayListFromArray2 - 2018.12.07 at 08h 40m 23s.xml">
408
+      <configuration name="ArrazTest.testMakeMeAnArrayListFromArray2" configurationId="JUnit" />
409
+    </history-entry>
412 410
   </component>
413 411
   <component name="TimeTrackingManager">
414
-    <option name="totallyTimeSpent" value="25688000" />
412
+    <option name="totallyTimeSpent" value="27639000" />
415 413
   </component>
416 414
   <component name="ToolWindowManager">
417 415
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
@@ -521,15 +519,23 @@
521 519
     </entry>
522 520
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
523 521
       <provider selected="true" editor-type-id="text-editor">
524
-        <state relative-caret-position="313">
525
-          <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
522
+        <state relative-caret-position="388">
523
+          <caret line="140" lean-forward="true" selection-start-line="140" selection-end-line="140" />
524
+          <folding>
525
+            <element signature="e#3351#3352#0" expanded="true" />
526
+            <element signature="e#3376#3377#0" expanded="true" />
527
+            <element signature="e#3440#3441#0" expanded="true" />
528
+            <element signature="e#3482#3483#0" expanded="true" />
529
+            <element signature="e#3556#3557#0" expanded="true" />
530
+            <element signature="e#3603#3604#0" expanded="true" />
531
+          </folding>
526 532
         </state>
527 533
       </provider>
528 534
     </entry>
529 535
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
530 536
       <provider selected="true" editor-type-id="text-editor">
531
-        <state relative-caret-position="167">
532
-          <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
537
+        <state relative-caret-position="372">
538
+          <caret line="294" column="44" selection-start-line="294" selection-start-column="44" selection-end-line="294" selection-end-column="44" />
533 539
           <folding>
534 540
             <element signature="imports" expanded="true" />
535 541
             <element signature="e#4388#4389#0" expanded="true" />

+ 11
- 0
arraz/src/main/java/Arraz.java Visa fil

@@ -126,4 +126,15 @@ public class Arraz {
126 126
         return integerSet.toArray(new Integer[0]);
127 127
     }
128 128
 
129
+    public double find2ndLargestValueFromArray(double[] array){
130
+        return 0.0;
131
+    }
132
+
133
+    public List<Integer> makeMeAnArrayListFromArray(Integer[] array){
134
+       return Arrays.asList(array);
135
+    }
136
+
137
+    public Integer[] makeMeAnArrayFromArrayList(List<Integer> list){
138
+        return list.toArray(new Integer[0]);
139
+    }
129 140
 }

+ 57
- 12
arraz/src/test/java/ArrazTest.java Visa fil

@@ -4,7 +4,9 @@ import org.junit.Assert;
4 4
 import org.junit.Before;
5 5
 import org.junit.Test;
6 6
 
7
+import java.util.ArrayList;
7 8
 import java.util.Arrays;
9
+import java.util.List;
8 10
 
9 11
 
10 12
 public class ArrazTest {
@@ -15,12 +17,14 @@ public class ArrazTest {
15 17
     private int[] arr1;
16 18
     private int[] arr2;
17 19
     private double[] double1;
20
+    private double[] double2;
18 21
 
19 22
     @Before
20 23
     public void before() {
21 24
         arr1 = new int[]{5, 10, 3, 29, 100};
22 25
         arr2 = new int[]{2, 7, 432, 89};
23 26
         double1 = new double[] {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
27
+        double2 =  new double[]{6.0, 2.897, 3.1, 654.3, 5.21, 78.9};
24 28
         testArraz = new Arraz();
25 29
         oddEven1 = new OddEven(3, 2);
26 30
         maxMin = new MaxMin(100,3);
@@ -237,16 +241,57 @@ public class ArrazTest {
237 241
         Assert.assertArrayEquals(expected, actual);
238 242
     }
239 243
 
240
-//    @Test
241
-//    public void testFind2ndLargestFromArray1(){
242
-//        double expected = 38.4;
243
-//        double actual = testArraz.find2ndLargestFromArray();
244
-//
245
-//        Assert.assertEquals(expected, actual, .01);
246
-//    }
247
-//
248
-//    @Test
249
-//    public void testFind2ndLargestFromArray2(){
250
-//
251
-//    }
244
+    @Test
245
+    public void testFind2ndLargestFromArray1(){
246
+        double expected = 38.4;
247
+        double actual = testArraz.find2ndLargestValueFromArray(double1);
248
+
249
+        Assert.assertEquals(expected, actual, .01);
250
+    }
251
+
252
+    @Test
253
+    public void testFind2ndLargestFromArray2(){
254
+        double expected = 78.9;
255
+        double actual = testArraz.find2ndLargestValueFromArray(double2);
256
+
257
+        Assert.assertEquals(expected, actual, .01);
258
+    }
259
+
260
+    @Test
261
+    public void testMakeMeAnArrayListFromArray1(){
262
+        List<Integer> expected= new ArrayList<>();
263
+        expected.add(5);
264
+        expected.add(4);
265
+        expected.add(3);
266
+        Integer[] array = new Integer[]{5, 4, 3};
267
+        List<Integer> actual = testArraz.makeMeAnArrayListFromArray(array);
268
+
269
+        Assert.assertEquals(expected, actual);
270
+    }
271
+
272
+    @Test
273
+    public void testMakeMeAnArrayListFromArray2(){
274
+        List<Integer> expected = new ArrayList<>();
275
+        expected.add(100);
276
+        expected.add(37);
277
+        expected.add(10);
278
+        expected.add(67);
279
+        Integer[] array = new Integer[]{100, 37, 10, 67};
280
+        List<Integer> actual = testArraz.makeMeAnArrayListFromArray(array);
281
+
282
+        Assert.assertEquals(expected, actual);
283
+    }
284
+
285
+    @Test
286
+    public void testMakeMeAnArrayFromArrayList1(){
287
+        Integer[] expected = new Integer[]{10, 7, 23, 50};
288
+        List<Integer> list = new ArrayList<>();
289
+        list.add(10);
290
+        list.add(7);
291
+        list.add(23);
292
+        list.add(50);
293
+        Integer[] actual = testArraz.makeMeAnArrayFromArrayList(list);
294
+
295
+        Assert.assertEquals(expected, actual);
296
+    }
252 297
 }