Skip to content

Commit

Permalink
Update tests from latest canonical data
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrigoriu committed Jan 30, 2019
1 parent 46f4090 commit 1377511
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 100 deletions.
14 changes: 13 additions & 1 deletion exercises/acronym/AcronymTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.5.0 of the canonical data.
// This file was auto-generated based on version 1.7.0 of the canonical data.

using Xunit;

Expand Down Expand Up @@ -45,4 +45,16 @@ public void Consecutive_delimiters()
{
Assert.Equal("SIMUFTA", Acronym.Abbreviate("Something - I made up from thin air"));
}

[Fact(Skip = "Remove to run test")]
public void Apostrophes()
{
Assert.Equal("HC", Acronym.Abbreviate("Halley's Comet"));
}

[Fact(Skip = "Remove to run test")]
public void Underscore_emphasis()
{
Assert.Equal("TRNT", Acronym.Abbreviate("The Road _Not_ Taken"));
}
}
2 changes: 1 addition & 1 deletion exercises/acronym/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public static string Abbreviate(string phrase)

private static IEnumerable<string> Words(string phrase)
{
return Regex.Matches(phrase, "[A-Z]+[a-z]*|[a-z]+").Cast<Match>().Select(m => m.Value);
return Regex.Matches(phrase, "[A-Z]+[a-z']*|[a-z']+").Cast<Match>().Select(m => m.Value);
}
}
16 changes: 12 additions & 4 deletions exercises/binary-search/BinarySearchTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.2.0 of the canonical data.
// This file was auto-generated based on version 1.3.0 of the canonical data.

using System;
using Xunit;
Expand Down Expand Up @@ -62,26 +62,34 @@ public void Identifies_that_a_value_is_not_included_in_the_array()
}

[Fact(Skip = "Remove to run test")]
public void A_value_smaller_than_the_arrays_smallest_value_is_not_included()
public void A_value_smaller_than_the_arrays_smallest_value_is_not_found()
{
var array = new[] { 1, 3, 4, 6, 8, 9, 11 };
var value = 0;
Assert.Equal(-1, BinarySearch.Find(array, value));
}

[Fact(Skip = "Remove to run test")]
public void A_value_larger_than_the_arrays_largest_value_is_not_included()
public void A_value_larger_than_the_arrays_largest_value_is_not_found()
{
var array = new[] { 1, 3, 4, 6, 8, 9, 11 };
var value = 13;
Assert.Equal(-1, BinarySearch.Find(array, value));
}

[Fact(Skip = "Remove to run test")]
public void Nothing_is_included_in_an_empty_array()
public void Nothing_is_found_in_an_empty_array()
{
var array = Array.Empty<int>();
var value = 1;
Assert.Equal(-1, BinarySearch.Find(array, value));
}

[Fact(Skip = "Remove to run test")]
public void Nothing_is_found_when_the_left_and_right_bounds_cross()
{
var array = new[] { 1, 2 };
var value = 0;
Assert.Equal(-1, BinarySearch.Find(array, value));
}
}
9 changes: 8 additions & 1 deletion exercises/bracket-push/BracketPushTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.4.0 of the canonical data.
// This file was auto-generated based on version 1.5.0 of the canonical data.

using Xunit;

Expand Down Expand Up @@ -102,6 +102,13 @@ public void Paired_and_incomplete_brackets()
Assert.False(BracketPush.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Too_many_closing_brackets()
{
var value = "[]]";
Assert.False(BracketPush.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Math_expression()
{
Expand Down
4 changes: 2 additions & 2 deletions exercises/gigasecond/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public static class Gigasecond
{
public static DateTime Add(DateTime birthDate)
public static DateTime Add(DateTime moment)
{
return birthDate.AddSeconds(1000000000);
return moment.AddSeconds(1000000000);
}
}
2 changes: 1 addition & 1 deletion exercises/gigasecond/Gigasecond.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public static class Gigasecond
{
public static DateTime Add(DateTime birthDate)
public static DateTime Add(DateTime moment)
{
throw new NotImplementedException("You need to implement this function.");
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/gigasecond/GigasecondTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.1.0 of the canonical data.
// This file was auto-generated based on version 2.0.0 of the canonical data.

using System;
using Xunit;
Expand Down
62 changes: 7 additions & 55 deletions exercises/hamming/HammingTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 2.1.0 of the canonical data.
// This file was auto-generated based on version 2.2.0 of the canonical data.

using System;
using Xunit;
Expand All @@ -12,73 +12,25 @@ public void Empty_strands()
}

[Fact(Skip = "Remove to run test")]
public void Identical_strands()
public void Single_letter_identical_strands()
{
Assert.Equal(0, Hamming.Distance("A", "A"));
}

[Fact(Skip = "Remove to run test")]
public void Long_identical_strands()
{
Assert.Equal(0, Hamming.Distance("GGACTGA", "GGACTGA"));
}

[Fact(Skip = "Remove to run test")]
public void Complete_distance_in_single_nucleotide_strands()
{
Assert.Equal(1, Hamming.Distance("A", "G"));
}

[Fact(Skip = "Remove to run test")]
public void Complete_distance_in_small_strands()
{
Assert.Equal(2, Hamming.Distance("AG", "CT"));
}

[Fact(Skip = "Remove to run test")]
public void Small_distance_in_small_strands()
{
Assert.Equal(1, Hamming.Distance("AT", "CT"));
}

[Fact(Skip = "Remove to run test")]
public void Small_distance()
public void Single_letter_different_strands()
{
Assert.Equal(1, Hamming.Distance("GGACG", "GGTCG"));
Assert.Equal(1, Hamming.Distance("G", "T"));
}

[Fact(Skip = "Remove to run test")]
public void Small_distance_in_long_strands()
{
Assert.Equal(2, Hamming.Distance("ACCAGGG", "ACTATGG"));
}

[Fact(Skip = "Remove to run test")]
public void Non_unique_character_in_first_strand()
{
Assert.Equal(1, Hamming.Distance("AAG", "AAA"));
}

[Fact(Skip = "Remove to run test")]
public void Non_unique_character_in_second_strand()
{
Assert.Equal(1, Hamming.Distance("AAA", "AAG"));
}

[Fact(Skip = "Remove to run test")]
public void Same_nucleotides_in_different_positions()
{
Assert.Equal(2, Hamming.Distance("TAG", "GAT"));
}

[Fact(Skip = "Remove to run test")]
public void Large_distance()
public void Long_identical_strands()
{
Assert.Equal(4, Hamming.Distance("GATACA", "GCATAA"));
Assert.Equal(0, Hamming.Distance("GGACTGAAATCTG", "GGACTGAAATCTG"));
}

[Fact(Skip = "Remove to run test")]
public void Large_distance_in_off_by_one_strand()
public void Long_different_strands()
{
Assert.Equal(9, Hamming.Distance("GGACGGATTCTG", "AGGACGGATTCT"));
}
Expand Down
8 changes: 7 additions & 1 deletion exercises/isogram/IsogramTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.6.0 of the canonical data.
// This file was auto-generated based on version 1.7.0 of the canonical data.

using Xunit;

Expand Down Expand Up @@ -52,6 +52,12 @@ public void Hypothetical_isogrammic_word_with_hyphen()
Assert.True(Isogram.IsIsogram("thumbscrew-japingly"));
}

[Fact(Skip = "Remove to run test")]
public void Hypothetical_word_with_duplicated_character_following_hyphen()
{
Assert.False(Isogram.IsIsogram("thumbscrew-jappingly"));
}

[Fact(Skip = "Remove to run test")]
public void Isogram_with_duplicated_hyphen()
{
Expand Down
14 changes: 13 additions & 1 deletion exercises/luhn/LuhnTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.2.0 of the canonical data.
// This file was auto-generated based on version 1.4.0 of the canonical data.

using Xunit;

Expand Down Expand Up @@ -46,12 +46,24 @@ public void Invalid_credit_card()
Assert.False(Luhn.IsValid("8273 1232 7352 0569"));
}

[Fact(Skip = "Remove to run test")]
public void Valid_number_with_an_even_number_of_digits()
{
Assert.True(Luhn.IsValid("095 245 88"));
}

[Fact(Skip = "Remove to run test")]
public void Valid_strings_with_a_non_digit_included_become_invalid()
{
Assert.False(Luhn.IsValid("055a 444 285"));
}

[Fact(Skip = "Remove to run test")]
public void Valid_strings_with_a_non_digit_added_at_the_end_become_invalid()
{
Assert.False(Luhn.IsValid("059a"));
}

[Fact(Skip = "Remove to run test")]
public void Valid_strings_with_punctuation_included_become_invalid()
{
Expand Down
4 changes: 2 additions & 2 deletions exercises/matrix/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public Matrix(string input)
public int Rows => _rows.Length;
public int Cols => _cols.Length;

public int[] Row(int row) => _rows[row];
public int[] Column(int col) => _cols[col];
public int[] Row(int row) => _rows[row - 1];
public int[] Column(int col) => _cols[col - 1];

private static int[][] ParseRows(string input)
{
Expand Down
18 changes: 9 additions & 9 deletions exercises/matrix/MatrixTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.0.0 of the canonical data.
// This file was auto-generated based on version 1.1.0 of the canonical data.

using Xunit;

Expand All @@ -8,55 +8,55 @@ public class MatrixTest
public void Extract_row_from_one_number_matrix()
{
var sut = new Matrix("1");
Assert.Equal(new[] { 1 }, sut.Row(0));
Assert.Equal(new[] { 1 }, sut.Row(1));
}

[Fact(Skip = "Remove to run test")]
public void Can_extract_row()
{
var sut = new Matrix("1 2\n3 4");
Assert.Equal(new[] { 3, 4 }, sut.Row(1));
Assert.Equal(new[] { 3, 4 }, sut.Row(2));
}

[Fact(Skip = "Remove to run test")]
public void Extract_row_where_numbers_have_different_widths()
{
var sut = new Matrix("1 2\n10 20");
Assert.Equal(new[] { 10, 20 }, sut.Row(1));
Assert.Equal(new[] { 10, 20 }, sut.Row(2));
}

[Fact(Skip = "Remove to run test")]
public void Can_extract_row_from_non_square_matrix()
{
var sut = new Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6");
Assert.Equal(new[] { 7, 8, 9 }, sut.Row(2));
Assert.Equal(new[] { 7, 8, 9 }, sut.Row(3));
}

[Fact(Skip = "Remove to run test")]
public void Extract_column_from_one_number_matrix()
{
var sut = new Matrix("1");
Assert.Equal(new[] { 1 }, sut.Column(0));
Assert.Equal(new[] { 1 }, sut.Column(1));
}

[Fact(Skip = "Remove to run test")]
public void Can_extract_column()
{
var sut = new Matrix("1 2 3\n4 5 6\n7 8 9");
Assert.Equal(new[] { 3, 6, 9 }, sut.Column(2));
Assert.Equal(new[] { 3, 6, 9 }, sut.Column(3));
}

[Fact(Skip = "Remove to run test")]
public void Can_extract_column_from_non_square_matrix()
{
var sut = new Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6");
Assert.Equal(new[] { 3, 6, 9, 6 }, sut.Column(2));
Assert.Equal(new[] { 3, 6, 9, 6 }, sut.Column(3));
}

[Fact(Skip = "Remove to run test")]
public void Extract_column_where_numbers_have_different_widths()
{
var sut = new Matrix("89 1903 3\n18 3 1\n9 4 800");
Assert.Equal(new[] { 1903, 3, 4 }, sut.Column(1));
Assert.Equal(new[] { 1903, 3, 4 }, sut.Column(2));
}
}
8 changes: 4 additions & 4 deletions exercises/matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ So given a string with embedded newlines like:
representing this matrix:

```text
0 1 2
1 2 3
|---------
0 | 9 8 7
1 | 5 3 2
2 | 6 6 7
1 | 9 8 7
2 | 5 3 2
3 | 6 6 7
```

your code should be able to spit out:
Expand Down
2 changes: 1 addition & 1 deletion exercises/phone-number/PhoneNumberTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.6.1 of the canonical data.
// This file was auto-generated based on version 1.7.0 of the canonical data.

using System;
using Xunit;
Expand Down
14 changes: 13 additions & 1 deletion exercises/rest-api/RestApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.0.2 of the canonical data.
// This file was auto-generated based on version 1.1.1 of the canonical data.

using Xunit;

Expand Down Expand Up @@ -98,4 +98,16 @@ public void Lender_owes_borrower_less_than_new_loan()
var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{\"Bob\":1.0},\"balance\":1.0},{\"name\":\"Bob\",\"owes\":{\"Adam\":1.0},\"owed_by\":{},\"balance\":-1.0}]";
Assert.Equal(expected, actual);
}

[Fact(Skip = "Remove to run test")]
public void Lender_owes_borrower_same_as_new_loan()
{
var url = "/iou";
var payload = "{\"lender\":\"Adam\",\"borrower\":\"Bob\",\"amount\":3.0}";
var database = "[{\"name\":\"Adam\",\"owes\":{\"Bob\":3.0},\"owed_by\":{},\"balance\":-3.0},{\"name\":\"Bob\",\"owes\":{},\"owed_by\":{\"Adam\":3.0},\"balance\":3.0}]";
var sut = new RestApi(database);
var actual = sut.Post(url, payload);
var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{},\"balance\":0.0},{\"name\":\"Bob\",\"owes\":{},\"owed_by\":{},\"balance\":0.0}]";
Assert.Equal(expected, actual);
}
}
4 changes: 3 additions & 1 deletion exercises/saddle-points/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class SaddlePoints
var columnCount = matrix.GetLength(1);
var maxRows = Rows(matrix, rowCount, columnCount).Select(r => r.Max()).ToArray();
var minCols = Columns(matrix, columnCount, rowCount).Select(r => r.Min()).ToArray();
return Coordinates(rowCount, columnCount).Where(x => IsSaddlePoint(x, maxRows, minCols, matrix))
return Coordinates(rowCount, columnCount)
.Where(x => IsSaddlePoint(x, maxRows, minCols, matrix))
.Select(pair => (pair.Item1 + 1, pair.Item2 + 1))
.ToArray();
}

Expand Down
Loading

0 comments on commit 1377511

Please sign in to comment.