コード例 #1
0
		netSize get_TolkenCount( netBuffer& buffer, const netString& tolken )
		{
			netSize hit_count(0);
			bool	hit(false);
			netSize idx;

			buffer.set_loc(0);
			while(buffer.good())
			{
				if(buffer.next()==tolken[0])
				{
					hit = true;
					for( idx = 1; idx < tolken.size(); idx++ )
					{
						if(buffer.next()!=tolken[idx])
						{
							hit = false;
							break;
						}
					}
				}
				if(hit)
					++hit_count;

				hit = false;
			}
			return hit_count;
		}
コード例 #2
0
		netSize get_WSCount( netBuffer& buffer )
		{
			netSize hit_count(0);
			buffer.set_loc(0);
			while(buffer.good())
			{
				if(buffer.next()==' ')
					++hit_count;
			}
			return hit_count;
		}
コード例 #3
0
ファイル: jotto.c プロジェクト: dblack/cjotto
static void *humans_turn(JottoGuess *hjg, char *c_word, JDict *reference)
{
    char h_guess[7];
    int h_hits = JOTTO_INVALID_HIT_COUNT;
  
    do {
	get_human_guess(h_guess);
	if (jdict_has_word(h_guess, reference)) {
	    h_hits = hit_count(h_guess, c_word); 
	}
	else {
	    printf("No such word; try again: ");
	}
    } while (h_hits == JOTTO_INVALID_HIT_COUNT);
  
    strncpy(hjg->guess, h_guess, 6);
    hjg->hits = h_hits;
}
コード例 #4
0
ファイル: jotto.c プロジェクト: dblack/cjotto
void test_5_hits() {
    int hits = hit_count("house", "house");
    CU_ASSERT(hits == 5);
}
コード例 #5
0
ファイル: jotto.c プロジェクト: dblack/cjotto
void test_hits_out_of_order_do_not_count() {
    int hits = hit_count("house", "eusoh");
    CU_ASSERT(hits == 0);
}
コード例 #6
0
ファイル: jotto.c プロジェクト: dblack/cjotto
void test_1_hits() {
    int hits = hit_count("house", "hello");
    CU_ASSERT(hits == 1);
}
コード例 #7
0
ファイル: jotto.c プロジェクト: dblack/cjotto
void test_no_hits() {
    int hits = hit_count("house", "trick");
    CU_ASSERT(hits == 0);
}