\begin{align*}
d &= 11 - \Biggl( \sum^{11}{n=1} P_n \times Q_n \Biggr) \bmod 11 \
& \text{ただし,$\Biggl( \sum^{11}{n=1} P_n \times Q_n \Biggr) \bmod 11 \leq 1$の場合は$d=0$} \
P_n &= \text{ 個人番号を構成する検査用数字以外の十一桁の番号の最下位の桁を1桁目としたときの$n$桁目の数字} \
Q_n &=
\begin{cases}
n + 1 && \text{if
Last active
December 17, 2015 13:37
-
-
Save izumin5210/e7023339a34665d2554a to your computer and use it in GitHub Desktop.
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
class MyNumberValidator | |
def validate(num) | |
# write your code here... | |
end | |
end |
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
require './mynumber_validator' | |
RSpec.describe MyNumberValidator do | |
let(:validator) { MyNumberValidator.new } | |
describe '#validate_mynumber' do | |
subject { validator.validate(num) } | |
context 'pass the number that has invalid length ' do | |
let(:num) { 12345678901 } | |
it { is_expected.to be false } | |
end | |
context 'pass the invalid number' do | |
let(:num) { 123456789012 } | |
it { is_expected.to be false } | |
end | |
context 'pass the valid number' do | |
let(:num) { 123456789018 } | |
it { is_expected.to be true } | |
end | |
context 'pass the invalid number that calculated digit is bigger' do | |
let(:num) { 123456789001 } | |
it { is_expected.to be false } | |
end | |
context 'pass the valid number that calculated digit is bigger' do | |
let(:num) { 123456789000 } | |
it { is_expected.to be true } | |
end | |
context 'pass the invalid number as string' do | |
let(:num) { '123456789012' } | |
it { is_expected.to be false } | |
end | |
context 'pass the valid number starts with 0' do | |
let(:num) { '023456789013' } | |
it { is_expected.to be true } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment