Sha256: 04e9bc1575ca624bc851194aa59fdf78e22691d0295abce00a4256f3fea736f4

Contents?: true

Size: 1.63 KB

Versions: 238

Compression:

Stored size: 1.63 KB

Contents

if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("grains.exs", __DIR__)
end

ExUnit.start
ExUnit.configure exclude: :pending, trace: true

# NOTE: :math.pow/2 doesn't do what you'd expect:
# `:math.pow(2, 64) == :math.pow(2, 64) - 1` is true.
#
# It's best to avoid functions operating on floating point numbers for very
# large numbers.

defmodule GrainsTest do
  use ExUnit.Case

  # @tag :pending
  test "square 1" do
    assert Grains.square(1) === { :ok, 1 }
  end

  @tag :pending
  test "square 2" do
    assert Grains.square(2) === { :ok, 2 }
  end

  @tag :pending
  test "square 3" do
    assert Grains.square(3) === { :ok, 4 }
  end

  @tag :pending
  test "square 4" do
    assert Grains.square(4) === { :ok, 8 }
  end

  @tag :pending
  test "square 16" do
    assert Grains.square(16) === { :ok, 32768 }
  end

  @tag :pending
  test "square 32" do
    assert Grains.square(32) === { :ok, 2147483648 }
  end

  @tag :pending
  test "square 64" do
    assert Grains.square(64) === { :ok, 9223372036854775808 }
  end

  @tag :pending
  test "total grains" do
    assert Grains.total === { :ok, 18446744073709551615 }
  end

  @tag :pending
  test "square greater than 64 returns an error" do
    assert Grains.square(65) === { :error, "The requested square must be between 1 and 64 (inclusive)" }
  end

  @tag :pending
  test "negative square returns an error" do
    assert Grains.square(-1) === { :error, "The requested square must be between 1 and 64 (inclusive)" }
  end

  @tag :pending
  test "square 0 returns an error" do
    assert Grains.square(0) === { :error, "The requested square must be between 1 and 64 (inclusive)" }
  end

end

Version data entries

238 entries across 238 versions & 1 rubygems

Version Path
trackler-2.2.1.109 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.108 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.107 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.106 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.105 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.104 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.103 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.102 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.101 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.100 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.99 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.98 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.97 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.96 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.95 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.94 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.93 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.92 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.91 tracks/elixir/exercises/grains/grains_test.exs
trackler-2.2.1.90 tracks/elixir/exercises/grains/grains_test.exs