From 7188d4b434a43fa03910c57d36e35cba02de13c5 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Wed, 11 Dec 2013 14:29:47 -0500 Subject: [PATCH] Move tests from QueryTest to IpAddressTest. --- test/ip_address_test.rb | 23 +++++++++++++++++++++++ test/query_test.rb | 7 ------- 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 test/ip_address_test.rb diff --git a/test/ip_address_test.rb b/test/ip_address_test.rb new file mode 100644 index 00000000..fcdcd809 --- /dev/null +++ b/test/ip_address_test.rb @@ -0,0 +1,23 @@ +# encoding: utf-8 +require 'test_helper' + +class IpAddressTest < Test::Unit::TestCase + + def test_valid + assert Geocoder::IpAddress.new("232.65.123.94").valid? + assert Geocoder::IpAddress.new("666.65.123.94").valid? # technically invalid + assert Geocoder::IpAddress.new("::ffff:12.34.56.78").valid? + assert !Geocoder::IpAddress.new("232.65.123.94.43").valid? + assert !Geocoder::IpAddress.new("232.65.123").valid? + assert !Geocoder::IpAddress.new("::ffff:123.456.789").valid? + assert !Geocoder::IpAddress.new("Test\n232.65.123.94").valid? + end + + def test_loopback + assert Geocoder::IpAddress.new("0.0.0.0").loopback? + assert Geocoder::IpAddress.new("127.0.0.1").loopback? + assert !Geocoder::IpAddress.new("232.65.123.234").loopback? + assert !Geocoder::IpAddress.new("127 Main St.").loopback? + assert !Geocoder::IpAddress.new("John Doe\n127 Main St.\nAnywhere, USA").loopback? + end +end diff --git a/test/query_test.rb b/test/query_test.rb index a7d588e9..6f68278b 100644 --- a/test/query_test.rb +++ b/test/query_test.rb @@ -5,12 +5,8 @@ class QueryTest < Test::Unit::TestCase def test_ip_address_detection assert Geocoder::Query.new("232.65.123.94").ip_address? - assert Geocoder::Query.new("666.65.123.94").ip_address? # technically invalid - assert Geocoder::Query.new("::ffff:12.34.56.78").ip_address? assert !Geocoder::Query.new("232.65.123.94.43").ip_address? - assert !Geocoder::Query.new("232.65.123").ip_address? assert !Geocoder::Query.new("::ffff:123.456.789").ip_address? - assert !Geocoder::Query.new("Test\n232.65.123.94").ip_address? end def test_blank_query_detection @@ -38,11 +34,8 @@ class QueryTest < Test::Unit::TestCase end def test_loopback_ip_address - assert Geocoder::Query.new("0.0.0.0").loopback_ip_address? assert Geocoder::Query.new("127.0.0.1").loopback_ip_address? assert !Geocoder::Query.new("232.65.123.234").loopback_ip_address? - assert !Geocoder::Query.new("127 Main St.").loopback_ip_address? - assert !Geocoder::Query.new("John Doe\n127 Main St.\nAnywhere, USA").loopback_ip_address? end def test_sanitized_text_with_array -- GitLab