Infeasible path example

De Software testing
Ir para: navegação, pesquisa

There is no executable path that includes the statements in lines 12 (valid_id = false) and 18 (return true).

public boolean validateIdentifier(String s) {
	char achar;
	boolean valid_id = false;
	achar = s.charAt(0);
	valid_id = valid_s(achar);
	if (s.length() > 1) {
		achar = s.charAt(1);
		int i = 1;
		while (i < s.length() - 1) {
			achar = s.charAt(i);
			if (! valid_f(achar))
				valid_id = false;
			i++;
		}
	}

	if (valid_id && (s.length() >= 1) && (s.length() < 6))
		return true;
	else
		return false;
}