From aab41d6fbab69e1973afdffd677869c58acbdfe9 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Mon, 11 May 2020 07:02:40 -0500 Subject: [PATCH] 16 failures --- README.md | 2 +- lib/pigeon.rb | 4 +++- spec/pigeon/helpers_spec.rb | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ea42ac6..12a4e96 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ See `kitchen_sink.sh` examples. - [X] Update Ruby API docs - [X] Update blobs spec to clear out blob folder every time it runs. - [ ] Oops, `lipmaa` field needs to be a hash, not an integer! - - [ ] Change draft and message templates to render headers in this order: `author`, `prev`, `lipmaa`, `kind`, `depth`. + - [ ] Change draft and message templates to render headers in this order: `author`, `prev`, `lipmaa`, `depth`, `kind`. - [ ] Make location of blob folder configurable? - [ ] Update Dev docs in protocol spec to reflect changes to `lipmaa` header. - [ ] Update spec document CLI usage examples to reflect API changes in 2020. diff --git a/lib/pigeon.rb b/lib/pigeon.rb index 2221e7e..e77d01c 100644 --- a/lib/pigeon.rb +++ b/lib/pigeon.rb @@ -89,7 +89,9 @@ module Pigeon # The original lipmaa function returns -1 for 0 # but that does not mesh well with our serialization # scheme. Comments welcome on this one. - return 0 if n < 1 # Prevent -1, division by zero etc.. + if n < 1 # Prevent -1, division by zero etc.. + return nil + end m, po3, x = 1, 3, n # find k such that (3^k - 1)/2 >= n diff --git a/spec/pigeon/helpers_spec.rb b/spec/pigeon/helpers_spec.rb index f66d3f1..d814600 100644 --- a/spec/pigeon/helpers_spec.rb +++ b/spec/pigeon/helpers_spec.rb @@ -1,20 +1,19 @@ RSpec.describe Pigeon::Helpers do it "creates lipmalinks" do [ - [-1, 0], - [0, 0], - [1, 0], - [2, 1], - [3, 2], + [-1, nil], + [0, nil], + [1, nil], + [2, nil], + [3, nil], [4, 1], - [5, 4], - [6, 5], - [7, 6], + [5, nil], + [6, nil], + [7, nil], [8, 4], [13, 4], - ].map do |(input, expected)| - actual = Pigeon::Helpers.lipmaa(input) - expect(actual).to eq(expected) + ].each do |(input, expected)| + expect(Pigeon::Helpers.lipmaa(input)).to eq(expected) end end