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
# See https://www.tutorialspoint.com/junit/junit_executing_tests.htm | |
# ~/.bash_profile | |
export JAVA_HOME=/Library/Java/Home | |
export JUNIT_HOME=/Library/JUNIT | |
export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit-4.10.jar:. | |
# TestJunit.java | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; |
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
# In the middle of implementing Boyer-Moore's string search algorithm, I decided to play with my original naive search algorithm. It's implemented as an instance method that takes a string to be searched. The object has an attribute 'pattern' which is the pattern to match. | |
# 1) Here is the original version of the search method, using a double for-loop. | |
# Makes calls to range and len | |
def search(self, string): | |
for i in range(len(string)): | |
for j in range(len(self.pattern)): | |
if string[i+j] != self.pattern[j]: | |
break |