Sha256: 2f6eb2c5cf09e3319120a04f4650054da8db45bdaf45c354744ec961312ff119

Contents?: true

Size: 1.56 KB

Versions: 69

Compression:

Stored size: 1.56 KB

Contents

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

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

defmodule SchoolTest do
  use ExUnit.Case

  @db %{}

  test "add student" do
    actual = School.add(@db, "Aimee", 2)
    assert actual == %{2 => ["Aimee"]}
  end

  @tag :pending
  test "add more students in same class" do
    actual =
      @db
      |> School.add("James", 2)
      |> School.add("Blair", 2)
      |> School.add("Paul", 2)

    assert Enum.sort(actual[2]) == ["Blair", "James", "Paul"]
  end

  @tag :pending
  test "add students to different grades" do
    actual =
      @db
      |> School.add("Chelsea", 3)
      |> School.add("Logan", 7)

    assert actual == %{3 => ["Chelsea"], 7 => ["Logan"]}
  end

  @tag :pending
  test "get students in a grade" do
    actual =
      @db
      |> School.add("Bradley", 5)
      |> School.add("Franklin", 5)
      |> School.add("Jeff", 1)
      |> School.grade(5)

    assert Enum.sort(actual) == ["Bradley", "Franklin"]
  end

  @tag :pending
  test "get students in a non existent grade" do
    assert [] == School.grade(@db, 1)
  end

  @tag :pending
  test "sort school by grade and by student name" do
    actual =
      @db
      |> School.add("Bart", 4)
      |> School.add("Jennifer", 4)
      |> School.add("Christopher", 4)
      |> School.add("Kareem", 6)
      |> School.add("Kyle", 3)
      |> School.sort()

    expected = [
      {3, ["Kyle"]},
      {4, ["Bart", "Christopher", "Jennifer"]},
      {6, ["Kareem"]}
    ]

    assert expected == actual
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.179 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.178 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.177 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.176 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.175 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.174 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.173 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.172 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.171 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.170 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.169 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.167 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.166 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.165 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.164 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.163 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.162 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.161 tracks/elixir/exercises/grade-school/grade_school_test.exs
trackler-2.2.1.160 tracks/elixir/exercises/grade-school/grade_school_test.exs