Skip to content

Commit

Permalink
test: Attributes value가 null인 key
Browse files Browse the repository at this point in the history
  • Loading branch information
sanhee committed Dec 22, 2021
1 parent 8dbb272 commit 41592da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/webserver/http/attribute/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ public int hashCode() {
return Objects.hash(attributes);
}


public int size(){
return attributes.size();
}

}
17 changes: 17 additions & 0 deletions src/test/java/webserver/http/attribute/AttributesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package webserver.http.attribute;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -13,6 +14,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.jupiter.api.Assertions.assertAll;

class AttributesTest {

Expand Down Expand Up @@ -156,4 +158,19 @@ void toHeaderText() {
assertThat(attributes.toHeaderText()).isEqualTo("key1: value1\r\nkey2: value2");

}

@Test
@DisplayName("value가 null인 key")
void isNullWhenNullValue(){
Attributes attributes = new Attributes();
attributes.add("null", null);
attributes.add("null2", null);

assertAll(
()-> assertThat(attributes.size()).isEqualTo(2),

This comment has been minimized.

Copy link
@Dae-Hwa

Dae-Hwa Dec 22, 2021

Collaborator

null을 판단하는데 사이즈를 비교해야할 이유가 있나요?

()-> assertThat(attributes.get("null")).isNull(),
()-> assertThat(attributes.get("null2")).isNull()
);

}
}

0 comments on commit 41592da

Please sign in to comment.