Initial callsigns taken from legacy code
1 files changed, 133 insertions(+), 0 deletions(-)

A => test/org/overchat/overham/modules/CallsignTest.java
A => test/org/overchat/overham/modules/CallsignTest.java +133 -0
@@ 0,0 1,133 @@ 
+/*
+ * OverHam; An object-orientated ham radio math and tool library
+ * Copyright (c) 2015-2018, Duncan Ross Palmer (2E0EOL),
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *
+ *     * Neither the name of the Daybo Logic nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.overchat.overham.modules;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CallsignTest {
+
+	private Callsign sut;
+
+	@Before
+	public void setUp() throws Exception {
+		this.sut = new Callsign();
+	}
+
+	@Test
+	public void testBritishGood() throws IllegalResistorException {
+ 74         $self->t('M0HDJ', 'GB', 'E', 'Full', 'amateur');
+ 75         $self->t('M1CEL', 'GB', 'E', 'Full', 'amateur');
+ 76         $self->t('M3JDK', 'GB', 'E', 'Foundation', 'amateur');
+ 77         $self->t('M6KVM', 'GB', 'E', 'Foundation', 'amateur');
+ 78         $self->t('MW6CTE','GB', 'W', 'Foundation', 'amateur');
+ 79         $self->t('G8DX',  'GB', 'E', 'Full', 'amateur');
+ 80         $self->t('G0XAY', 'GB', 'E', 'Full', 'amateur');
+ 81         $self->t('G1FUA', 'GB', 'E', 'Full', 'amateur');
+ 82         $self->t('G2BAR', 'GB', 'E', 'Full', 'amateur');
+ 83         $self->t('G3XOB', 'GB', 'E', 'Full', 'amateur');
+ 84         $self->t('G4NFS', 'GB', 'E', 'Full', 'amateur');
+ 85         $self->t('G5XXX', 'GB', 'E', 'Full', 'amateur');
+ 86         $self->t('G6PNB', 'GB', 'E', 'Full', 'amateur');
+ 87         $self->t('G7FBD', 'GB', 'E', 'Full', 'amateur');
+ 88         $self->t('G8YMM', 'GB', 'E', 'Full', 'amateur');
+ 89         $self->t('G9XXX', 'GB', 'E', 'Full', 'commercial');
+ 90         $self->t('2E0HOQ','GB', 'E', 'Intermediate', 'amateur');
+ 91         $self->t('2W0CGM','GB', 'W', 'Intermediate', 'amateur');
+ 92         $self->t('2W1ACM','GB', 'W', 'Intermediate', 'amateur');
+ 93         $self->t('M0NBC', 'GB', 'E', 'Full', 'amateur');
+ 94         $self->t('MX0NBC','GB', 'X', 'Club', 'amateur');
+ 95 
+ 96         # Special NoVs
+ 97         $self->t('MR6KVM','GB', 'R', 'Foundation', 'amateur');
+ 98         $self->t('MQ6KVM','GB', 'Q', 'Foundation', 'amateur');
+ 99         $self->t('MV6KVM','GB', 'V', 'Foundation', 'amateur');
+100 
+101         $self->t('MR3JDK','GB', 'R', 'Foundation', 'amateur');
+102         $self->t('MQ3JDK','GB', 'Q', 'Foundation', 'amateur');
+103         $self->t('MV3JDK','GB', 'V', 'Foundation', 'amateur');
+104 
+105         $self->t('2R0PGS','GB', 'R', 'Intermediate', 'amateur');
+106         $self->t('2Q0PGS','GB', 'Q', 'Intermediate', 'amateur');
+107         $self->t('2V0PGS','GB', 'V', 'Intermediate', 'amateur');
+108 
+109         $self->t('GQ5FM', 'GB', 'Q', 'Full', 'amateur');
+110 
+111         $self->t('M2ZZ', 'GB', 'E', 'Full', 'police') ;# Police
+112         $self->t('MRG23', 'GB', '', 'unknown', 'military'); # Military
+	}
+
+	@Test
+	public void testBritishBad() throws IllegalResistorException {
+120         $self->x('M0YY', 'GB', 'E', 'Full', 'amateur'); # M0 must have 2-letter suffix
+121         $self->x('2X0ABC' ,'GB', 'X', 'Intermediate', 'amateur'); # Cannot have an intermediate club call
+122         $self->x('MX6ABC' ,'GB', 'X', 'Foundation', 'amateur'); # Cannot have a foundation club call
+123 
+124         subtest 'unallocated M' => sub {
+125                 my @unallocated = (qw/2 4 7 8 9/);
+126                 plan tests => scalar(@unallocated) * 5;
+127 
+128                 foreach my $badm (@unallocated) {
+129                         my $type = ($badm == 2) ? ('police') : ('amateur');
+130                         $self->x(sprintf('M%uBAR', $badm), 'GB', 'E', 'Full', $type); # This M block is not allocated
+131                 }
+132         };
+133 
+134         subtest 'qCodes' => sub { # Q-code suffixes are not allocated
+135                 plan tests => 3 * 5;
+136 
+137                 $self->x('M6QMA', 'GB', 'E', 'Foundation', 'amateur');
+138                 $self->x('2E0QSL', 'GB', 'E', 'Intermediate', 'amateur');
+139                 $self->x('M0QSL', 'GB', 'E', 'Full', 'amateur');
+140         };
+	}
+
+	@Test
+	public void testBritishRepeater() throws IllegalResistorException {
+147         $self->t('GB2BC', 'GB', '', 'Special', 'amateur');
+148         $self->t('GB3BS', 'GB', '', 'Repeater', 'amateur');
+149         $self->t('MB6IBS','GB', '', 'Repeater', 'amateur');
+150         $self->t('MB6BS', 'GB', '', 'Repeater', 'amateur');
+151         $self->t('GB3BS', 'GB', '', 'Repeater', 'amateur');
+152         $self->t('GB7BS', 'GB', '', 'Repeater', 'amateur');
+153         $self->t('GB7AA', 'GB', '', 'Repeater', 'amateur');
+154         $self->t('GB3UB', 'GB', '', 'Repeater', 'amateur');
+155         $self->t('GB3AA', 'GB', '', 'Repeater', 'amateur');
+156         $self->t('MB7IFH','GB', '', 'Repeater', 'amateur');
+157         $self->t('GB3WES','GB', '', 'Beacon', 'amateur');
+158         $self->t('GB3ORL','GB', '', 'Beacon', 'amateur');
+159         $self->t('GB3REL','GB', '', 'Beacon', 'amateur');
+	}
+}