Skip to content

Instantly share code, notes, and snippets.

@instanceofme
Created January 17, 2013 17:37
Show Gist options
  • Save instanceofme/4557820 to your computer and use it in GitHub Desktop.
Save instanceofme/4557820 to your computer and use it in GitHub Desktop.
// in './'
organization := "com.stackoverflow"
name := "legal"
version := "0.1"
scalaVersion := "2.9.1"
resolvers += "Imaginatio" at "https://github.com/Imaginatio/Maven-repository/raw/master"
libraryDependencies += "fr.splayce" %% "rel" % "0.2.3"
libraryDependencies += "org.specs2" %% "specs2" % "1.10" % "test"
scalacOptions ++= Seq("-deprecation", "-unchecked", "-encoding", "UTF8")
// in './src/test/scala/'
package com.stackoverflow.legal
import fr.splayce.rel.Implicits.RE2Regex
import org.specs2.mutable._
class LegalSpec extends Specification {
import Legal._
"NAME" should {
"Match plain names" in {
"Doe" must be matching(NAME)
"Smith" must be matching(NAME)
}
"Not match composed names" in {
"Doe-Smith" must not be matching(NAME)
}
"Not match diacritics" in {
"Doë" must not be matching(NAME)
}
}
"CASE" should {
"Match 'vs' form" in { "Doe vs Smith" must be matching(CASE) }
"Match 'v.s' form" in { "Doe v.s Smith" must be matching(CASE) }
"Match 'v.s.' form" in { "Doe v.s. Smith" must be matching(CASE) }
"Match 'v' form" in { "Doe v Smith" must be matching(CASE) }
"Match 'v.' form" in { "Doe v. Smith" must be matching(CASE) }
}
"NUM" should {
"Match 1+ digits" in {
"1" must be matching(NUM)
"12" must be matching(NUM)
"123" must be matching(NUM)
"1234" must be matching(NUM)
"12345" must be matching(NUM)
"123456" must be matching(NUM)
}
"Match only standalone digits" in {
NUM.findFirstIn(" 123 ") must beSome("123")
NUM.findFirstIn(" n123 ") must beNone
}
}
"US" should {
"Match 'US ' form" in { "US " must be matching(US) }
"Match 'U.S. ' form" in { "U.S. " must be matching(US) }
"Match 'U. S. ' form" in { "U. S. " must be matching(US) }
}
"YEAR" should {
"Not match 1600s" in {
"1699" must not be matching(YEAR)
}
"Match 1700s to 1900s" in {
"1700" must be matching(YEAR)
"1799" must be matching(YEAR)
"1800" must be matching(YEAR)
"1899" must be matching(YEAR)
"1900" must be matching(YEAR)
"1999" must be matching(YEAR)
}
"Match 2000s" in {
"2000" must be matching(YEAR)
"2099" must be matching(YEAR)
}
"Not match 2100s" in {
"2100" must not be matching(YEAR)
}
}
"REF" should {
"Match the full form" in {
"Doe v. Smith, U.S. 456 (2003)" must be matching(REF)
"Doe v. Smith, 123 U.S. 456 (2003)" must be matching(REF)
"Doe v. Smith, 123 U.S. 456, 789 (2003)" must be matching(REF)
"Doe v.s. Smith, 123 US 456 (2003)" must be matching(REF)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment