File: key_equality.rb

package info (click to toggle)
ruby-rbnacl 7.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 700 kB
  • sloc: ruby: 2,884; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# encoding: binary
# frozen_string_literal: true

RSpec.shared_examples "key equality" do
  context "equality" do
    it "equal keys are equal" do
      expect(described_class.new(key_bytes) == key).to be true
    end
    it "equal keys are equal to the string" do
      expect(key == key_bytes).to be true
    end
    it "keys are not equal to zero" do
      expect(key == RbNaCl::Util.zeros(32)).to be false
    end
    it "keys are not equal to another key" do
      expect(key == other_key).to be false
    end
  end

  context "lexicographic sorting" do
    it "can be compared lexicographically to a key smaller than it" do
      expect(key > RbNaCl::Util.zeros(32)).to be true
    end
    it "can be compared lexicographically to a key larger than it" do
      expect(described_class.new(RbNaCl::Util.zeros(32)) < key).to be true
    end
  end
end