Index: wp-testcase/test_link_functions.php
===================================================================
--- wp-testcase/test_link_functions.php	(revision 718)
+++ wp-testcase/test_link_functions.php	(working copy)
@@ -82,6 +82,78 @@
 			}
 		}
 	}
+
+	function test_set_url_scheme() {
+		if ( ! function_exists( 'set_url_scheme' ) )
+			return;
+
+		$links = array(
+			'http://wordpress.org/',
+			'https://wordpress.org/',
+			'http://wordpress.org/news/',
+			'http://wordpress.org',
+		);
+
+		$https_links = array(
+			'https://wordpress.org/',
+			'https://wordpress.org/',
+			'https://wordpress.org/news/',
+			'https://wordpress.org',
+		);
+
+		$http_links = array(
+			'http://wordpress.org/',
+			'http://wordpress.org/',
+			'http://wordpress.org/news/',
+			'http://wordpress.org',
+		);
+
+		$relative_links = array(
+			'/',
+			'/',
+			'/news/',
+			''
+		);
+
+		$forced_admin = force_ssl_admin();
+		$forced_login = force_ssl_login();
+		$i = 0;
+		foreach ( $links as $link ) {
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'https' ) );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'http' ) );
+			$this->assertEquals( $relative_links[ $i ], set_url_scheme( $link, 'relative' ) );
+
+			$_SERVER['HTTPS'] = 'on';
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link ) );
+
+			$_SERVER['HTTPS'] = 'off';
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link ) );
+
+			force_ssl_login( false );
+			force_ssl_admin( true );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'admin' ) );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'login_post' ) );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'login' ) );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'rpc' ) );
+
+			force_ssl_admin( false );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'admin' ) );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'login_post' ) );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'login' ) );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'rpc' ) );
+
+			force_ssl_login( true );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'admin' ) );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'login_post' ) );
+			$this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'login' ) );
+			$this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'rpc' ) );
+
+			$i++;
+		}
+
+		force_ssl_admin( $forced_admin );
+		force_ssl_login( $forced_login );
+	}
 }
 
 ?>
