New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter max length 280 #198

Closed
wants to merge 9 commits into
base: master
from
Copy path View file
@@ -5,18 +5,22 @@ tests:
text: "I am a Tweet"
expected: true

- description: "Valid Tweet: 140 characters"
- description: "Valid Tweet: 280 characters"
text: "A lie gets halfway around the world before the truth has a chance to get its pants on. Winston Churchill (1874-1965) http://bit.ly/dJpywL"
expected: true

- description: "Valid Tweet: 140 characters (with accents)"
- description: "Valid Tweet: 280 characters (with accents)"
text: "A lié géts halfway arøünd thé wørld béføré thé truth has a chance tø get its pants øn. Winston Churchill (1874-1965) http://bit.ly/dJpywL"
expected: true

- description: "Valid Tweet: 140 characters (double byte characters)"
- description: "Valid Tweet: 280 characters (double byte characters)"
text: "のののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののの"
expected: true

- description: "Valid Tweet: 140 characters (Chinnese)"
text: "一二三四五六七八九,一二三四五六七八九十一二三四五六七八九;一二三四五六七八九十一二三四五六七八九。一二三四五六七八九十一二三四五六七八九十一二三四五六七八九:一二三四五六七八九。一二三四五六七八九,一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九。"
expected: true

- description: "Valid Tweet: 140 characters (double word characters)"
text: "\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431\U0001f431"
expected: true
@@ -25,12 +29,20 @@ tests:
text: ""
expected: false

- description: "Invalid Tweet: 141 characters"
text: "A lie gets halfway around the world before the truth has a chance to get its pants on. -- Winston Churchill (1874-1965) http://bit.ly/dJpywL"
- description: "Invalid Tweet: 281 characters"
text: "A lie gets halfway around the world before the truth has a chance to get its pants on. Winston Churchill (1874-1965) http://bit.ly/dJpywL A lie gets halfway around the world before the truth has a chance to get its pants on. Winston Churchill (1874-1965) http://bit.ly/dJpywL"
expected: false

- description: "Invalid Tweet: 281 characters (due to newline)"
text: "A lie gets halfway around the world before the truth has a chance to get its pants on.\nWinston Churchill (1874-1965) http://bit.ly/dJpywL A lie gets halfway around the world before the truth has a chance to get its pants on. Winston Churchill (1874-1965) http://bit.ly/dJpywL"
expected: false

- description: "Invalid Tweet: 281 characters (double byte characters)"
text: "ののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののののの"
expected: false

- description: "Invalid Tweet: 141 characters (due to newline)"
text: "A lie gets halfway around the world before the truth has a chance to get its pants on. \n- Winston Churchill (1874-1965) http://bit.ly/dJpywL"
- description: "Invalid Tweet: 141 characters (Chinese)"
text: "一二三四五六七八九,一二三四五六七八九十一二三四五六七八九;一二三四五六七八九十一二三四五六七八九。一二三四五六七八九十一二三四五六七八九十一二三四五六七八九:一二三四五六七八九。一二三四五六七八九,一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九。,"
expected: false

usernames:
@@ -6,7 +6,7 @@
* A class for validating Tweet texts.
*/
public class Validator {
public static final int MAX_TWEET_LENGTH = 140;
public static final int MAX_TWEET_LENGTH = 280;

protected int shortUrlLength = 23;
protected int shortUrlLengthHttps = 23;
@@ -26,7 +26,7 @@ public void testDirectionChangeCharacters() {
public void testAccentCharacters() {
String c = "\u0065\u0301";
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 139; i++) {
for (int i = 0; i < 279; i++) {
builder.append(c);
}
assertTrue(validator.isValidTweet(builder.toString()));
@@ -37,7 +37,7 @@ public void testAccentCharacters() {
public void testMutiByteCharacters() {
String c = "\ud83d\ude02";
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 139; i++) {
for (int i = 0; i < 279; i++) {
builder.append(c);
}
assertTrue(validator.isValidTweet(builder.toString()));
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.