Skip to content

Commit

Permalink
Add unit tests of GistUriMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki committed Nov 28, 2012
1 parent 79433b1 commit 971b43b
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/******************************************************************************
* Copyright (c) 2012 GitHub Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
*****************************************************************************/
package com.github.mobile.tests.gist;

import android.net.Uri;
import android.test.AndroidTestCase;

import com.github.mobile.core.gist.GistUriMatcher;

import org.eclipse.egit.github.core.Gist;

/**
* Unit tests of {@link GistUriMatcher}
*/
public class GistUriMatcherTest extends AndroidTestCase {

/**
* Verify empty uri
*/
public void testEmptyUri() {
assertNull(GistUriMatcher.getGist(Uri.parse("")));
}

/**
* Verify invalid Gist ids in URIs
*/
public void testNonGistId() {
assertNull(GistUriMatcher.getGist(Uri
.parse("https://gist.github.com/TEST")));
assertNull(GistUriMatcher.getGist(Uri
.parse("https://gist.github.com/abc%20")));
assertNull(GistUriMatcher.getGist(Uri
.parse("https://gist.github.com/abcdefg")));
}

/**
* Verify public Gist id
*/
public void testPublicGist() {
Gist gist = GistUriMatcher.getGist(Uri
.parse("https://gist.github.com/1234"));
assertNotNull(gist);
assertEquals("1234", gist.getId());
}

/**
* Verify public Gist id
*/
public void testPrivateGist() {
Gist gist = GistUriMatcher.getGist(Uri
.parse("https://gist.github.com/abcd1234abcd1234abcd"));
assertNotNull(gist);
assertEquals("abcd1234abcd1234abcd", gist.getId());
}
}

0 comments on commit 971b43b

Please sign in to comment.