-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
ec661aa
commit 691102a
Showing
4 changed files
with
81 additions
and
6 deletions.
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
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
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
31 changes: 31 additions & 0 deletions
31
test/com/deepak/ctci/Ch05_Bit_Manipulation/Problem_01_Test.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,31 @@ | ||
/** | ||
* Cracking-The-Coding-Interview | ||
* Problem_01_Test.java | ||
*/ | ||
package com.deepak.ctci.Ch05_Bit_Manipulation; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.deepak.ctci.Library.HelperMethods; | ||
|
||
/** | ||
* Test cases for Problem 01 | ||
* | ||
* @author Deepak | ||
*/ | ||
public class Problem_01_Test { | ||
|
||
/** | ||
* Method to test merging of bits from M to N | ||
*/ | ||
@Test | ||
public void testMergeOfBits() { | ||
int N = 103217; | ||
int M = 13; | ||
Assert.assertEquals(HelperMethods.toFullBinaryString(N, 32), "0000 0000 0000 0001 1001 0011 0011 0001"); | ||
Assert.assertEquals(HelperMethods.toFullBinaryString(M, 32), "0000 0000 0000 0000 0000 0000 0000 1101"); | ||
Assert.assertEquals(HelperMethods.toFullBinaryString(Problem_01.mergeMIntoN(103217, 13, 4, 12), 32), "0000 0000 0000 0001 1000 0000 1101 0001"); | ||
} | ||
|
||
} |