summaryrefslogblamecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala
blob: 9a029d8f6b287dda5f897db0549ab6a4440b513d (plain) (tree)
1
2
3
4
5
6
7
8
9
                                             
 
                                             




                                                   
                                         
 



                                                          


                                                                                             



                                                                 


                                                                                                



                                                                         


                                                                                             



                                                                            


                                                                                              



                                 






                                                                                            


                            
                                                    
 
package com.rockymadden.stringmetric.phonetic

import com.rockymadden.stringmetric.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class MetaphoneMetricSpec extends ScalaTest {
	import MetaphoneMetricSpec.Metric

	"MetaphoneMetric" should provide {
		"compare method" when passed {
			"empty arguments" should returns {
				"None" in {
					Metric.compare("", "").isDefined should be (false)
					Metric.compare("abc", "").isDefined should be (false)
					Metric.compare("", "xyz").isDefined should be (false)
				}
			}
			"non-phonetic arguments" should returns {
				"None" in {
					Metric.compare("123", "123").isDefined should be (false)
					Metric.compare("123", "").isDefined should be (false)
					Metric.compare("", "123").isDefined should be (false)
				}
			}
			"phonetically similar arguments" should returns {
				"Boolean indicating true" in {
					Metric.compare("dumb", "dum").get should be (true)
					Metric.compare("smith", "smeth").get should be (true)
					Metric.compare("merci", "mercy").get should be (true)
				}
			}
			"phonetically dissimilar arguments" should returns {
				"Boolean indicating false" in {
					Metric.compare("dumb", "gum").get should be (false)
					Metric.compare("smith", "kiss").get should be (false)
					Metric.compare("merci", "burpy").get should be (false)
				}
			}
		}
	}
	"MetaphoneMetric companion object" should provide {
		"pass-through compare method" should returns {
			"same value as class" in {
				MetaphoneMetric.compare("dumb", "gum").get should be (false)
			}
		}
	}
}

object MetaphoneMetricSpec {
	final private val Metric = MetaphoneMetric()
}