The automatic test data generation technology tries to find a relatively small set of test data to satisfy adequacy criterion, in order to reduce testing cost and increase testing efficiency. In this paper, an innovative test data generation algorithm based on maintaining population diversity is proposed, which satisfies condition/decision coverage criterion. This algorithm is based on an extended branch coverage table. Normalized Manhattan distance is employed to calculate the diversity between test data and eliminate the data with lower diversity, to maintain population diversity. Meanwhile, a new approach is introduced to evaluate the fitness values of test data. Then a greedy algorithm is used to reduce the number of test cases. Finally, this paper presents some experiments over a large benchmark composed of fourteen programs that include fundamental and practical aspects of computer science.